Skip to content

UNITO_User_Interface/mainGUI.py generates ImportError, missing PyQt5 #2

@MorselHoarder

Description

@MorselHoarder

Hi,
Thanks for all your hard work on UNITO! 🙂 Looking forward to trying it out.

Upon a fresh install with anaconda I'm getting an error when running the mainGUI.py module.

$ cd UNITO/UNITO_User_Interface/
$ python mainGUI.py
Traceback (most recent call last):
  File "/home/schult/UNITO/UNITO_User_Interface/mainGUI.py", line 4, in <module>
    from matplotlib.backends.backend_qt5agg import FigureCanvasQTAgg as FigureCanvas
  File "/home/schult/anaconda3/envs/UNITO_demo/lib/python3.9/site-packages/matplotlib/backends/backend_qt5agg.py", line 7, in <module>
    from .backend_qtagg import (    # noqa: F401, E402 # pylint: disable=W0611
  File "/home/schult/anaconda3/envs/UNITO_demo/lib/python3.9/site-packages/matplotlib/backends/backend_qtagg.py", line 9, in <module>
    from .qt_compat import QT_API, QtCore, QtGui
  File "/home/schult/anaconda3/envs/UNITO_demo/lib/python3.9/site-packages/matplotlib/backends/qt_compat.py", line 130, in <module>
    raise ImportError(
ImportError: Failed to import any of the following Qt binding modules: PyQt5, PySide2

To reproduce, I followed the anaconda installation instructions in UNITO_User_Interface/README.md exactly.

$ conda create --name UNITO_demo python=3.9
$ conda activate UNITO_demo
$ conda install pytorch::pytorch torchvision torchaudio -c pytorch
$ conda install anaconda::numpy pandas matplotlib seaborn scipy scikit-learn pyqt
$ conda install -c conda-forge opencv albumentations datashader

I noticed mainGUI.py uses PyQt5, however the most recent version of pyqt installed with conda's default channel is version 6.

$ conda list
...
pyqt           6.7.1           py39h8dad735_2
pyqt6-sip      13.9.1          py39h6ce4db3_2
...

I tried solving this by installing some form of PyQt5 using conda, but the default and anaconda channels don't have a PyQt5-specific package available. I also tried uninstalling pyqt and reinstalling with a pinned version conda install 'pyqt<6', but the python version pinned would require making significant version pins in other packages.

I solved this by running pip install pyqt5 in the UNITO_demo environment. The working conda list looks like this:

$ conda list
pyqt                           6.7.1            py39h8dad735_2
pyqt5                          5.15.11          pypi_0                        pypi
pyqt5-qt5                      5.15.17          pypi_0                        pypi
pyqt5-sip                      12.17.0          pypi_0                        pypi
pyqt6-sip                      13.9.1           py39h6ce4db3_2

While this is a simple fix, I would highly recommend generating some sort of requirements.txt or other lock file with version pins to avoid future package problems.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions