0

I'm writing a python script but, at the moment, I do everything from the Qgis python console. Is there a way to write and run a pyqgis script externally from Qgis?

I'm using Qgis 2.18 and python 2.7.12 on Ubuntu 16.04 OS.

Domenico Fuoco
  • 287
  • 3
  • 16
  • Is your python code designed to run within a running qgis, perhaps manipulating layers already loaded? Then use your IDE to edit and save, and then import mything; mything.dostuff() from the console is all you need. Write your code as a python module. – Spacedman Aug 31 '17 at 14:59

2 Answers2

1

You may like to try installing and configuring Pycharm. There's an blog article here : How to setup PyCharm for QGIS development (under Debian/Ubuntu) describing how to configure all this.

gisnside
  • 7,818
  • 2
  • 29
  • 73
0

Download and install anaconda from here https://www.continuum.io/downloads.

open the python shell of anaconda Type this command to install qgis

conda install -c conda-forge qgis

The you can import qgis in python

if the above solution does not workout well for you, try this in your python console.

import sys
sys.path.append("C:\Program Files\QGIS Pisa\apps\Python27\Lib")

import qgis.core

change the qgis path as per your config

Sandeep Kumar
  • 633
  • 4
  • 12