pydm icon indicating copy to clipboard operation
pydm copied to clipboard

PyDm fails with PyQt5 installed from Homebrew on Mac

Open pjyoung opened this issue 3 years ago • 1 comments

I have installed V1.11.1 following instructions from http://slaclab.github.io/pydm/. I first setup my standalone environment using instructions at http://slaclab.github.io/pydm/installation.html and https://www.riverbankcomputing.com/static/Docs/PyQt5/installation.html#building-and-installing-from-source

When starting up pydm I get the following error: bash-3.2$ pydm _Traceback (most recent call last): File "/usr/local/bin/pydm", line 8, in sys.exit(main()) File "/usr/local/lib/python3.9/site-packages/pydm_launcher/main.py", line 15, in main from pydm.utilities import setup_renderer File "/usr/local/lib/python3.9/site-packages/pydm/init.py", line 1, in from .application import PyDMApplication File "/usr/local/lib/python3.9/site-packages/pydm/application.py", line 16, in from .main_window import PyDMMainWindow File "/usr/local/lib/python3.9/site-packages/shiboken2/files.dir/shibokensupport/feature.py", line 142, in _import return original_import(name, *args, **kwargs) File "/usr/local/lib/python3.9/site-packages/pydm/main_window.py", line 6, in from .utilities import (IconFont, find_file, establish_widget_connections, File "/usr/local/lib/python3.9/site-packages/shiboken2/files.dir/shibokensupport/feature.py", line 142, in _import return original_import(name, *args, **kwargs) File "/usr/local/lib/python3.9/site-packages/pydm/utilities/init.py", line 15, in from .iconfont import IconFont File "/usr/local/lib/python3.9/site-packages/shiboken2/files.dir/shibokensupport/feature.py", line 142, in import return original_import(name, *args, **kwargs) File "/usr/local/lib/python3.9/site-packages/pydm/utilities/iconfont.py", line 10, in from qtpy.QtCore import Qt, QRect, QPoint, qRound ImportError: cannot import name 'qRound' from 'qtpy.QtCore' (/usr/local/lib/python3.9/site-packages/qtpy/QtCore.py)

I am running with PyQt5 v5.15.4_2 and Qt v5.15.2 with python 3.9.6 all installed with Mac Homebrew on macOS 11.4. I have tried removing the immediate dependency on qRound but then pydm fails trying to load QVariant: ImportError: cannot import name 'QVariant' from 'qtpy.QtCore' (/usr/local/lib/python3.9/site-packages/qtpy/QtCore.py)

Any advice?

pjyoung avatar Aug 16 '21 05:08 pjyoung

Hi @pjyoung, PyDM uses a module called 'qtpy' to try and paper over the differences between (PyQt4, PyQt5, and PySide2). From the errors, it looks like qtpy has decided to use PySide2 instead of PyQt. But - PySide2 doesn't expose the qRound function at all, which we use.

You can force qtpy to use a particular Python-Qt binding using the QT_API environment variable. Try doing export QT_API=pyqt5 before running PyDM, and see if that fixes it...

mattgibbs avatar Aug 20 '21 19:08 mattgibbs