Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error when importing QtCore with QGIS 3.22 (LTR) #1

Open
amr66 opened this issue Mar 24, 2022 · 6 comments
Open

Error when importing QtCore with QGIS 3.22 (LTR) #1

amr66 opened this issue Mar 24, 2022 · 6 comments

Comments

@amr66
Copy link

amr66 commented Mar 24, 2022

I get an error using VSCode with your approach on new QGIS LTR 3.22:

Exception has occurred: ImportError
DLL load failed while importing QtCore: Das angegebene Modul wurde nicht gefunden.
  File "[E:\am\dev\gisstick\gisstick_x64\VSCode\test_workspace\pyqgis-standalone-main\qtcore_test.py]()", line 1, in <module>
    from PyQt5.QtCore import QSettings

I only changed your launch.json to use the ${file} variable. The error occurs also with other IDE's, like PyScripter, so may be this is an OSGeo4W problem?

@MarByteBeep
Copy link
Owner

If it also happens with other IDE's perhaps it's a problem with that version. Could you try installing an older version? I'm running 3.16.16. If that version does work, please consider raising an issue with the QGIS dev team.

@amr66
Copy link
Author

amr66 commented Mar 28, 2022

Yes, thank you very much. I'm preparing a portable install of QGIS/Python for a USB memory stick, but I stuck with the PyQt5-Module. Does it work for you to import PyQt5.QtCore? Like this: from PyQt5.QtCore import QSettings. That would help me a lot.
--- added:
I found out that using from qgis.PyQt.QtCore import QSettings works. So I have at least a workaround.

@kannes
Copy link

kannes commented Jan 29, 2023

Importing the Qt stuff via qgis.PyQt.* is the recommended way anyways so I think this can be closed.

@amr66
Copy link
Author

amr66 commented Feb 1, 2023

I agree, but a last little thing I found out: Since Python 3.8 many packages for windows cant rely on the path variable anymore but should do this in their __init__.py instead:

    import os
    for p in os.getenv("PATH").split(";"):
    if os.path.exists(p):
        os.add_dll_directory(p)

If an IDE supports to run a little startup script for the python console, then this script can be run from there.

@kannes
Copy link

kannes commented Feb 2, 2023

Hm, first time I hear about such issue. Is there more info available somewhere?

@amr66
Copy link
Author

amr66 commented Feb 2, 2023

I think this comes near: https://stackoverflow.com/questions/71645822/dll-not-found-after-switching-from-python-3-7-6-to-python-3-10-3
Also I discussed this with the maker of PyScripter: pyscripter/pyscripter#1169

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants