When I try to load qgis within an external Python instance, I get the following error:
>>> from PyQt4.QtCore import *
>>> from PyQt4.QtGui import *
>>> import qgis
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "E:\QGIS\apps\qgis\python\qgis\__init__.py", line 27, in <module>
from qgis.core import QgsFeature, QgsGeometry
File "E:\QGIS\apps\qgis\python\qgis\core\__init__.py", line 30, in <module>
from qgis._core import *
ImportError: DLL load failed: The specified procedure could not be found.
QGIS version: 2.16.1.
Python in QGIS:
>>> print(sys.version)
2.7.5 (default, May 15 2013, 22:44:16) [MSC v.1500 64 bit (AMD64)]
Python installation:
>>> print(sys.version)
2.7.12 (v2.7.12:d33e0cf91556, Jun 27 2016, 15:24:40) [MSC v.1500 64 bit (AMD64)]
Paths in Python installation:
>>> print(sys.path)
['', 'E:\\QGIS\\apps\\qgis\\python', ...
Additionally the following paths are set in the environment of Windows:
E:\QGIS\apps\qgis\python;E:\QGIS\apps\qgis\bin;
Any idea how to fix this? Or how shall I setup my system to be able to access QGIS "interactively" from external Python IDEs ?
Best Answer
For those still trying to make this work, here is my working configuration (with QGIS 2.14 LTR) to launch PyCharm with a fully working QGIS environment.
Note that with the above configuration (saved as a .bat file to launch pycharm) it still misses something in the IDE to get syntax completion for the QGIS API.