3

Since using the new installer for the x64 only version OSGeo4W/QGIS (new 3.22 LTR), I can't no longer use PyScripter with the bundled PyQt5. When I try to import QSettings for example, PyScripter can't find the needed DLL for QtCore (Qt5Core.dll in apps\qt5). When I do the same on the OSGeo4W shell, python imports without any problems. I use similar batch files to start python and PyScripter based on the bin\python-qgis-ltr.bat file:

@echo off
call "%~dp0\bin\o4w_env.bat"
@echo off
path %OSGEO4W_ROOT%\apps\qgis-ltr\bin;%PATH%
set QGIS_PREFIX_PATH=%OSGEO4W_ROOT:\=/%/apps/qgis-ltr
set GDAL_FILENAME_IS_UTF8=YES
rem Set VSI cache to be used as buffer, see #6448
set VSI_CACHE=TRUE
set VSI_CACHE_SIZE=1000000
set QT_PLUGIN_PATH=%OSGEO4W_ROOT%\apps\qgis-ltr\qtplugins;%OSGEO4W_ROOT%\apps\qt5\plugins
set PYTHONPATH=%OSGEO4W_ROOT%\apps\qgis-ltr\python;%PYTHONPATH%
pause
cd %~dp0\PyScripter
start "PyScripter" /B "PyScripter.exe" --PYTHON39 --PYTHONDLLPATH=%OSGEO4W_ROOT%\apps\Python39

my test.py:

from PyQt5.QtCore import QSettings

As I said, Python successfully imports QSettings while PyScripter does give me this error:

>>> from PyQt5.QtCore import QSettings
Traceback (most recent call last):
  File "<interactive input>", line 1, in <module>
ImportError: DLL load failed while importing QtCore: Das angegebene Modul wurde nicht gefunden.

So, I don't know what I am missing, it used to work for QGIS <= 3.16.

3
  • Thanks for your hints! I will prove this. Python is 3.9, PyScripter is 4.1.1. Pyscripter works with that Python, I can run code, etc. Generally Dll's are found through the PATH variable, but that's seems not to be case here. Mar 24, 2022 at 6:50
  • My path, before calling PyScripter is PATH=C:\OSGeo4W\apps\qgis-ltr\bin;C:\OSGeo4W\apps\qt5\bin;C:\OSGeo4W\apps\Python39\Scripts;C:\OSGeo4W\bin;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\system32\WBem and it is set in call "%~dp0\bin\o4w_env.bat" plus path %OSGEO4W_ROOT%\apps\qgis-ltr\bin;%PATH%. This works for python.exe but not for PyScripter. Mar 24, 2022 at 9:36
  • I found out that using the import like this from qgis.PyQt.QtCore import QSettings works. So I have at least a workaround. Mar 28, 2022 at 16:28

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.