Thursday 28 March 2019

pyqgis - PyCharm 2019 is not working with QGIS anymore


Since the update to PyCharm 2019 I am unable to load the QGIS Python modules. I can not use auto completion either. I already deleted the cache (by invalidating the cache in PyCharm and also by deleting the "system" folder in the user settings directory), nothing seems to work.


When starting the Python console inside of PyCharm and typing "import qgis.core", I get the following error:


Traceback (most recent call last):
File "", line 1, in
File "C:\Program Files\JetBrains\PyCharm Community Edition 2018.2.2\helpers\pydev\_pydev_bundle\pydev_import_hook.py", line 21, in do_import
module = self._system_import(name, *args, **kwargs)
File "C:\OSGEO4~1\apps\qgis-ltr\python\qgis\core\__init__.py", line 27, in
from qgis._core import *
File "C:\Program Files\JetBrains\PyCharm Community Edition 2018.2.2\helpers\pydev\_pydev_bundle\pydev_import_hook.py", line 21, in do_import

module = self._system_import(name, *args, **kwargs)
ImportError: DLL load failed: Das angegebene Modul wurde nicht gefunden.

Something seems to be broken, in PyCharm 2018.3 everything was ok. The sys.path environments and interpreter settings seem to be correct:


['C:\\Program Files\\JetBrains\\PyCharm Community Edition '
'2018.2.2\\helpers\\pydev',
'C:\\OSGEO4~1\\apps\\qgis-ltr\\python',
'C:\\OSGEO4~1\\apps\\qgis-ltr\\python\\plugins',
'C:\\Program Files\\JetBrains\\PyCharm Community Edition '
'2018.2.2\\helpers\\third_party\\thriftpy',

'C:\\Program Files\\JetBrains\\PyCharm Community Edition '
'2018.2.2\\helpers\\pydev',
'C:\\OSGeo4W64\\apps\\Python37\\python37.zip',
'C:\\OSGEO4~1\\apps\\Python37\\DLLs',
'C:\\OSGEO4~1\\apps\\Python37\\lib',
'C:\\OSGeo4W64\\apps\\Python37',
'C:\\OSGEO4~1\\apps\\Python37',
'C:\\OSGEO4~1\\apps\\Python37\\lib\\site-packages',
'C:\\OSGEO4~1\\apps\\Python37\\lib\\site-packages\\win32',
'C:\\OSGEO4~1\\apps\\Python37\\lib\\site-packages\\win32\\lib',

'C:\\OSGEO4~1\\apps\\Python37\\lib\\site-packages\\Pythonwin']

Has anyone updated PyCharm to 2019 and can confirm this? I also reinstalled the whole QGIS installation, but nothing seems to work.


It looks like the DLLs containing the stubs are incompatible now?


My bat for starting PyCharm looks like this:


@echo off
SET OSGEO4W_ROOT=C:\OSGeo4W64
call "%OSGEO4W_ROOT%"\bin\o4w_env.bat
call "%OSGEO4W_ROOT%"\apps\grass\grass-7.4.2\etc\env.bat
@echo off

path %PATH%;%OSGEO4W_ROOT%\apps\qgis\bin
path %PATH%;%OSGEO4W_ROOT%\apps\grass\grass-7.4.2\lib
path %PATH%;%OSGEO4W_ROOT%\apps\Qt5\bin
path %PATH%;%OSGEO4W_ROOT%\apps\Python37\Scripts
path %PATH%;C:\Program Files\Docker\Docker\Resources\bin
path %PATH%;C:\Program Files\7-Zip

set QT_PLUGIN_PATH=C:\OSGeo4W64\apps\Qt5\plugins

set PYTHONPATH=%PYTHONPATH%;%OSGEO4W_ROOT%\apps\qgis-ltr\python

set PYTHONPATH=%PYTHONPATH%;%OSGEO4W_ROOT%\apps\qgis-ltr\python\plugins
set PYTHONHOME=%OSGEO4W_ROOT%\apps\Python37

start "PyCharm aware of Quantum GIS" /B "C:\Program Files\JetBrains\PyCharm Community Edition 2018.2.2\bin\pycharm64.exe" %*


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...