I was hoping someone could help me get Spyder working with QGIS. I am finding the python editor limiting within QGIS as I would like to debug my code, use the variable explorer, and be able to run highlighted code. I have tried two routes:

Route 1: Install Spyder within the OSGeo4W QGIS python instance

I installed OSGeo4W Network Installer (64 bit) v3.2 and opened OSGeo4W Shell and typed:

python -m pip install spyder

But I am getting errors in my IPython console:

SyntaxError: invalid syntax
File "C:\OSGEO4~1\apps\Python36\lib\site.py", line 177

Also, when I put in

from qgis.core import *
import qgis.utils

into my python script, it complains with unable to detect undefined names

I noticed all the QGIS files are in C:\OSGeo4W64\apps\qgis\

Route 2: Create new conda environment and install QGIS via conda

I used the install instructions at this url: https://anaconda.org/conda-forge/qgis

I create a new conda environment and then typed:

conda install -c conda-forge qgis 
conda install spyder
start spyder

My IPython console is fine (i.e. no errors as route 1), but I get errors when trying to import qgis.core etc into my script as in route 1.

I noticed that conda installed all the QGIS files to C:\Users\<user_name>\AppData\Local\Continuum\miniconda3\envs\<my_env>\Library\

Would anyone have any idea how to get this working?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.