I cannot set up the correct interpreter for PyQGIS 3 in PyCharm 2018.3.7.
Using: QGIS 3.12.0, OSGeo4W64, Python 3.7 (part of the OSGeo4W64 folder), PyCharm 2018.3.7.
My .cmd files in OSGeo4W64 look like this:
pyqgis.cmd:
SET OSGEO4W_ROOT=C:\OSGeo4W64
call "%OSGEO4W_ROOT%"\bin\o4w_env.bat
@echo off
path %PATH%;%OSGEO4W_ROOT%\apps\qgis\bin
path %PATH%;%OSGEO4W_ROOT%\apps\grass\grass-78\lib
path %PATH%;C:\OSGeo4W64\apps\Qt5\bin
path %PATH%;C:\OSGeo4W64\apps\Python37\Scripts
set PYTHONPATH=%PYTHONPATH%;%OSGEO4W_ROOT%\apps\qgis\python
set PYTHONHOME=%OSGEO4W_ROOT%\apps\Python37
set PATH=C:\Program Files\Git\bin;%PATH%
cmd.exe
pycharm.cmd:
SET OSGEO4W_ROOT=C:\OSGeo4W64
call "%OSGEO4W_ROOT%"\bin\o4w_env.bat
@echo off
path %PATH%;%OSGEO4W_ROOT%\apps\qgis\bin
path %PATH%;%OSGEO4W_ROOT%\apps\grass\grass-78\lib
path %PATH%;C:\OSGeo4W64\apps\Qt5\bin
path %PATH%;C:\OSGeo4W64\apps\Python37\Scripts
set PYTHONPATH=%PYTHONPATH%;%OSGEO4W_ROOT%\apps\qgis\python
set PYTHONHOME=%OSGEO4W_ROOT%\apps\Python37
set PATH=C:\Program Files\Git\bin;%PATH%
start "PyCharm aware of QGIS" /B "C:\Program Files\JetBrains\PyCharm Community Edition 2018.3.7\bin\pycharm64.exe" %*
After running pyqgis.cmd I can import different QGIS packages so everything seems ok. Running the pycharm.cmd file I can directly access PyCharm.
In PyCharm I´ve just defined the location of the new project and the path for the project interpreter which should be located in the OSGeo4W64 folder:
C:\OSGeo4W64\bin\python3.exe
But in the system settings the project interpreter ist still different:
The project interpreter is not the base interpreter. After trying to add a new interpreter I onl get the pip and and setuptool python packages and to not the PyQGIS packages:
After creating a new .py file in the project I can run some PyQGIS code (import some QGIS packages e.g.) but cannot run the code in the script window.
Maybe the SDK is missing but I didn´t get any error messages so I think this is not the issue.
Could you tell me what I´m doing wrong?
The .cmd files are based on:
Environment Setup for Plugin Development with QGIS 3
Some GIS Stack Exchange references (unfortunately haven’t brought me further):