[GIS] How to control QGIS from within Anaconda’s Spyder (Continuum Analytics Python distribution) in Windows

anacondacompilepythonqgis

I would like to control QGIS from within Anaconda's Spyder, in particular use the QGIS core modules.

My config:

Windows 7
Anaconda 64x for Python 2.7
Spyder 2.3
Postgresql 9.4
PostGIS 2.1
QGIS 2.8 (Wien)

Unfortunately it seems (from several answer I read) that one needs to recompile the distribution prior to be able to do that.

So I came to read this documentation on the github:
https://raw.githubusercontent.com/qgis/QGIS/master/INSTALL

I don't quite see where it is that one can modify the python distribution enclosed into the install. Could anyone give me some comments or a starting point to build an Anaconda compatible distribution of QGIS?

Best Answer

If you're not 100% stuck with your Anaconda distro you can try this:

What I do is install QGIS from OSGEO4W rather than standalone. This way I get a complete python environment with QT and many more things.

After installing OSGEO4W you'll need pip. This is how to get it: https://trac.osgeo.org/osgeo4w/wiki/ExternalPythonPackages

Then you can pip install any python package you use from the Anaconda distro. I use NumPy, SciPy, CV2 etc.

Also you can install spyder from source after downloading the spyder source:

python setup.py install

Here's an answer I posted for running spyder with QGIS (and GRASS) modules imported: Using Spyder IDE to develop python for Grass GIS, get 'ImportError: No module named grass.script'

I know I come from GIS so it was not a problem for me to have my python environment based on OSGEO4W, you might have other considerations naturally.