Saturday, 25 February 2017

python - How to import qgis.core in spyder?


I used to use spyder as python IDE and was learning QGIS developing recently. But I cannot import qgis.core in spyder although the library can be imported in QGIS Desktop Console successfully.


qgis desktop


Here is my setting environment:


My OS is Windows 7;


Spyder was integrated in Anaconda2-4.1.1-Windows-x86_64 and install together, in which default interpreter is Python 2.7.12(64bit)


QGIS 2.18 was installed by Standalone installer 64bit but python is 2.7.5 64bit. Then I modified the environment variables by appending


“C:\Program Files\QGIS 2.18\apps\qgis\python” in PYTHONPATH and



“C:\Program Files\QGIS 2.18\apps\qgis\bin;


C:\Program Files\QGIS 2.18\apps\qgis\python;


C:\Program Files\QGIS 2.18\apps\qgis\python\qgis\core;” in Path.


However, I still cannot import it in Spyder’s IPython, error says”DLL load failed:” spyder import Same error even I change the interpreter to QGIS’s 2.7.5 with Desktop open.


spyder change default


In term of OSGeo4W Shell, that is another problem.


Still failed to import it when finding no module at first opening, but it works only once if run Germán Carrillo’s BAT file. OSGeo4W


Which means that I have to run this batch file every time I start OSGeo4W Shell.


So it is weird my addition path in PATH and PYTHONPATH have no effect at all.




No comments:

Post a Comment

arcpy - Changing output name when exporting data driven pages to JPG?

Is there a way to save the output JPG, changing the output file name to the page name, instead of page number? I mean changing the script fo...