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

ThreediToolbox 1.16: ImportError: cannot import name 'sip' from 'PyQt5' #548

Closed
CornelisD opened this issue Mar 26, 2021 · 3 comments
Closed

Comments

@CornelisD
Copy link

CornelisD commented Mar 26, 2021

ThreediToolbox 1.16 install error:

Couldn't load plugin 'ThreeDiToolbox' due to an error when calling its classFactory() method
ImportError: cannot import name 'sip' from 'PyQt5' (C:\PROGRA~1\QGIS3~1.16\apps\Python37\lib\site-packages\PyQt5\__init__.py) 
Traceback (most recent call last):
  File "C:/PROGRA~1/QGIS3~1.16/apps/qgis-ltr/./python\qgis\utils.py", line 334, in _startPlugin
    plugins[packageName] = package.classFactory(iface)
  File "C:/Users/CornDawg/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\ThreeDiToolbox\__init__.py", line 42, in classFactory
    dependencies.check_importability()
  File "C:/Users/CornDawg/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\ThreeDiToolbox\dependencies.py", line 250, in check_importability
    imported_package = importlib.import_module(package)
  File "C:\PROGRA~1\QGIS3~1.16\apps\Python37\lib\importlib\__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "", line 1006, in _gcd_import
  File "", line 983, in _find_and_load
  File "", line 967, in _find_and_load_unlocked
  File "", line 677, in _load_unlocked
  File "", line 728, in exec_module
  File "", line 219, in _call_with_frames_removed
  File "C:/Users/CornDawg/AppData/Roaming/QGIS/QGIS3\profiles\default/python\pyqtgraph\__init__.py", line 13, in 
    from .Qt import QtGui, mkQApp
  File "C:/PROGRA~1/QGIS3~1.16/apps/qgis-ltr/./python\qgis\utils.py", line 792, in _import
    mod = _builtin_import(name, globals, locals, fromlist, level)
  File "C:/Users/CornDawg/AppData/Roaming/QGIS/QGIS3\profiles\default/python\pyqtgraph\Qt.py", line 137, in 
    from PyQt5 import QtGui, QtCore, QtWidgets, sip, uic
ImportError: cannot import name 'sip' from 'PyQt5' (C:\PROGRA~1\QGIS3~1.16\apps\Python37\lib\site-packages\PyQt5\__init__.py)

Python version: 3.7.0 (v3.7.0:1bf9cc5093, Jun 27 2018, 04:59:51) [MSC v.1914 64 bit (AMD64)]
QGIS version: 3.16.5-Hannover Hannover, 58ba7c1ed6
Python Path:

C:/PROGRA~1/QGIS3~1.16/apps/qgis-ltr/./pythonC:/Users/CornDawg/AppData/Roaming/QGIS/QGIS3\profiles\default/pythonC:/Users/CornDawg/AppData/Roaming/QGIS/QGIS3\profiles\default/python/pluginsC:/PROGRA~1/QGIS3~1.16/apps/qgis-ltr/./python/pluginsC:\PROGRA~1\QGIS3~1.16\apps\Python37C:\PROGRA~1\QGIS3~1.16\apps\Python37\ScriptsC:\Program Files\QGIS 3.16\bin\python37.zipC:\PROGRA~1\QGIS3~1.16\apps\Python37\DLLsC:\PROGRA~1\QGIS3~1.16\apps\Python37\libC:\Program Files\QGIS 3.16\binC:\PROGRA~1\QGIS3~1.16\apps\Python37\lib\site-packagesC:\PROGRA~1\QGIS3~1.16\apps\Python37\lib\site-packages\win32C:\PROGRA~1\QGIS3~1.16\apps\Python37\lib\site-packages\win32\libC:\PROGRA~1\QGIS3~1.16\apps\Python37\lib\site-packages\PythonwinC:\Users\CornDawg\AppData\Roaming\QGIS\QGIS3\profiles\default\python\plugins\HCMGIS/formsC:/Users/CornDawg/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\qgis2webC:\Users\CornDawg\AppData\Roaming\QGIS\QGIS3\profiles\default\python\pluginsC:/Users/CornDawg/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\tuflowC:\Users\CornDawg\AppData\Roaming\QGIS\QGIS3\profiles\default\python\plugins\tuflowC:\Users\CornDawg\AppData\Roaming\QGIS\QGIS3\profiles\default\python\plugins\tuflow/formsC:\Users\CornDawg\AppData\Roaming\QGIS\QGIS3\profiles\default\python\plugins\tuflowC:\Users\CornDawg\AppData\Roaming\QGIS\QGIS3\profiles\default\python\plugins\tuflowC:\Users\CornDawg\AppData\Roaming\QGIS\QGIS3\profiles\default\python\plugins\tuflow\tuflowqgis_tuviewerC:\Program Files\JetBrains\PyCharm 2019.2\debug-eggsC:\Program Files\JetBrains\PyCharm 2019.2\plugins\python\helpers\pydevC:\Program Files\JetBrains\PyCharm 2019.1.3\debug-eggsC:\Program Files\JetBrains\PyCharm 2019.1.3\helpers\pydev
@reinout
Copy link
Member

reinout commented Mar 31, 2021

This error should be impossible, as "sip" is bundled with pyqt5. But.... a combination of unexpected/undesired behaviour, a corner case and a bug made it possible after all.

There is a new pip option we could use, but that might need a newer pip than is included with qgis/python3.7, so using it might actually break the install.

Anyway, that is the very creative way in which this importerror occurred :-)

@reinout
Copy link
Member

reinout commented Mar 31, 2021

Actually, what I wrote above is too creative. The actual problem is simpler.

pyqtgraph released 0.12 on 25 march 2021, just a week ago. It includes this change: pyqtgraph/pyqtgraph@30a64d5#diff-82c45b216a85d25c95e4983b8c9ef44904bad1e5c6fafbec2abe74ef3ca7196cR137
Which is the exact line where the ImportError: cannot import name 'sip' from 'PyQt5' comes from.

The import should be fine, as that import works since pyqt version 5.11, see https://www.riverbankcomputing.com/static/Docs/PyQt5/incompatibilities.html#pyqt-v5-11

But.... if I look at the PyQt version, I see the older 5.10, released early 2018:

>>> QtCore.PYQT_VERSION_STR
'5.10.1'

Which is the version used on our "ubuntu bionic" test servers and local development docker. On linux, the pyqtgraph 0.11.1 that we bundle, is actually used and works just fine. 0.12 isn't used.
Somehow on windows, 0.12 is used even though 0.11.1 is bundled with the installer. I'm trying to fix that by forcing our installer to use versions below 0.12 (See #549).

@reinout
Copy link
Member

reinout commented Apr 1, 2021

I've released 1.17 of the plugin, which hopefully fixes the issue.
Someone at the office is checking whether you can upgrade the plugin or whether a fresh install is needed.

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