I use PyQGIS in standalone apps and I have defined paths in Windows and Python paths to take Python API from outside QGIS.
I have created some simple tools using PyQGIS and GDAL in standalone script using Python editor and all work fine without error qgis.core
and GDAL
work nice.
Now I want to use PyCharm editor and I have big problems.
First, it shows me two interpreters python.exe
and bin/python.exe
but have some paths.
Now in PyCharm if I use python.exe
, it shows me dll error in GDAL
and qgis.core
. If i use Python from QGIS then I have imports error
in other packages i need.
Why does it do that?
In Python, IDLE works fine.
Here the windows define paths :
pythonpath
C:\OSGeo4W64\apps\qgis-ltr\python
C:\OSGeo4W64\apps\qgis-ltr\plugins
C:\OSGeo4W64\apps\Python27\Lib\site-packages
path
C:\OSGeo4W64\bin
C:\OSGeo4W64\apps\qgis-ltr\bin
C:\OSGeo4W64\share\gdal
C:\Python27\
C:\Python27\Scripts
I think so the problems is the paths.
I have installed Python version 2.7.13 QGIS have his python... if in the define paths QGIS python path is below from PYTHON path then QGIS Python API don't work, if I change order and is above then work but recognizes site-packages from QGIS PYTHON ONLY...that I think is error
import sys; print(sys.path)
What does it say?['', 'C:\\Python27\\Lib\\idlelib', 'C:\\OSGeo4W64\\apps\\qgis-ltr\\python', 'C:\\OSGeo4W64\\apps\\qgis-ltr\\plugins', 'C:\\OSGeo4W64\\apps\\Python27\\Lib\\site-packages', 'C:\\WINDOWS\\SYSTEM32\\python27.zip', 'C:\\Python27\\DLLs', 'C:\\Python27\\lib', 'C:\\Python27\\lib\\plat-win', 'C:\\Python27\\lib\\lib-tk', 'C:\\Python27', 'C:\\Python27\\lib\\site-packages']