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

Why is having a qt binding raising a runtime error? #459

Open
goanpeca opened this issue Nov 23, 2023 · 15 comments
Open

Why is having a qt binding raising a runtime error? #459

goanpeca opened this issue Nov 23, 2023 · 15 comments
Labels
maintenance upstream Caused by upstream issues

Comments

@goanpeca
Copy link

Hello team, while working on conda-forge/recorder-napari-feedstock#7

I got this

import: 'recOrder'
Traceback (most recent call last):
  File "/home/conda/feedstock_root/build_artifacts/recorder-napari_1700522820524/test_tmp/run_test.py", line 2, in <module>
    import recOrder
  File "/home/conda/feedstock_root/build_artifacts/recorder-napari_1700522820524/_test_env_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_/lib/python3.11/site-packages/recOrder/__init__.py", line 5, in <module>
    raise RuntimeError(
RuntimeError: Please remove PyQt5 from your environment with `pip uninstall PyQt5`

Checking the code I found this file

https://github.com/mehta-lab/recOrder/blob/d31ad910abf84c65ba927e34561f916651cbb3e8/recOrder/plugin/__init__.py

Why is having a qt binding installed raising a runtime error?

@goanpeca goanpeca changed the title Why is having a qt bidning raising a runtime error? Why is having a qt binding raising a runtime error? Nov 28, 2023
@ziw-liu
Copy link
Contributor

ziw-liu commented Jan 3, 2024

Hi @goanpeca we are forcing Qt6 to avoid compatibility issues on Apple Arm platforms, as PyQt5 is not built for macOS arm64 on PyPI. Since we wrote our code for the Qt6 bindings, an error is raised when a Qt5 binding is in the environment (#409). We are open to suggestions to better handle this.

@ziw-liu ziw-liu added maintenance upstream Caused by upstream issues labels Jan 3, 2024
@goanpeca
Copy link
Author

goanpeca commented Jan 4, 2024

Hi @ziw-liu thanks for the response.

Well, for starters the error being raised does not explain that:

RuntimeError: Please remove PyQt5 from your environment with `pip uninstall PyQt5`

We need have minimum testing of recipes on conda-forge, so since qt6 is not an option at the moment, I am tempted to patch that part of the code to remove that and avoid having that issue.

@ziw-liu
Copy link
Contributor

ziw-liu commented Jan 5, 2024

@goanpeca I agree that the error message can be improved.

I am tempted to patch that part of the code to remove that and avoid having that issue.

We are using Qt6-specific API and using Qt5 instead is known to break certain GUI functionality. Feel free to patch the code on your side if that suits the testing purpose.

I just checked that PyQt5 v5.15.10 released Oct 2023 included a new macOS_arm64 build, which was not available in previous versions. I think we can consider moving back to Qt5 in the next version to avoid this problem.

@ziw-liu
Copy link
Contributor

ziw-liu commented Jun 11, 2024

so since qt6 is not an option at the moment

@goanpeca As I understand Qt6 is available on conda-forge: https://anaconda.org/conda-forge/qt6-main/.

@dbcortes2042000
Copy link

@goanpeca As I understand Qt6 is available on conda-forge: https://anaconda.org/conda-forge/qt6-main/.

Windows 11 user here. I just followed all the download instructions and get the same PyQt5 warning. I installed Qt6-main and still get the same warning. I also notice napari literally just released 0.5.3 today, would that cause issues?

Any workarounds to make recOrder work in my situation?

@dbcortes2042000
Copy link

Actually, I should say that after installing Qt6-main, the error message changes to "QTBindingsNotFoundError: No Qt bindings could be found"

So Qt6-main is not recognized... help.

@ziw-liu
Copy link
Contributor

ziw-liu commented Aug 30, 2024

Actually, I should say that after installing Qt6-main, the error message changes to "QTBindingsNotFoundError: No Qt bindings could be found"

So Qt6-main is not recognized... help.

Are you installing the latest stable version from PyPI?

@dbcortes2042000
Copy link

Are you installing the latest stable version from PyPI?

I just did a fresh install:
conda create -y -n recOrder python=3.10 conda activate recOrder pip install PyQt6 pip install recOrder-napari[acq]

When I try to open recOrder with napari I get:

raise RuntimeError( RuntimeError: Failed to import command at 'recOrder.plugin.main_widget:MainWidget': [WinError 126] The specified module could not be found. Error loading "C:\Users\cortesadmin\anaconda3\envs\recOrder\lib\site-packages\torch\lib\fbgemm.dll" or one of its dependencies.

@dbcortes2042000
Copy link

dbcortes2042000 commented Aug 30, 2024

I also tried PyQt 6.7.0 (previous version), 6.6.1 and 6.6.0. 6.6.0 gave the original error of not finding any qt bindings. 6.6.1 gave this error:
from PyQt6 import QtGui ImportError: DLL load failed while importing QtGui: The specified procedure could not be found.

6.7.0 gave the same error as 6.7.1 (latest version on PyPi)

Worth noting, napari runs fine with PyQt6 6.7.1 but when I try to open napari with recOrder I get the same error as before.

@ziw-liu
Copy link
Contributor

ziw-liu commented Aug 30, 2024

@dbcortes2042000 Thanks for a detailed report. We will investigate.

@dbcortes2042000
Copy link

@dbcortes2042000 Thanks for a detailed report. We will investigate.

Any update on this? I have the microscope assembled and ready to go, would be nice to have a workaround!

@ziw-liu
Copy link
Contributor

ziw-liu commented Sep 9, 2024

Are you installing the latest stable version from PyPI?

I just did a fresh install: conda create -y -n recOrder python=3.10 conda activate recOrder pip install PyQt6 pip install recOrder-napari[acq]

When I try to open recOrder with napari I get:

raise RuntimeError( RuntimeError: Failed to import command at 'recOrder.plugin.main_widget:MainWidget': [WinError 126] The specified module could not be found. Error loading "C:\Users\cortesadmin\anaconda3\envs\recOrder\lib\site-packages\torch\lib\fbgemm.dll" or one of its dependencies.

@dbcortes2042000 There seems to be two issues. This PyTorch one seems to be resolved in PyTorch 2.4.1 (released Sept 4): https://discuss.pytorch.org/t/failed-to-import-pytorch-fbgemm-dll-or-one-of-its-dependencies-is-missing/

Edit: Note that this a Windows quirk and not Qt-related.

@ziw-liu
Copy link
Contributor

ziw-liu commented Sep 9, 2024

@dbcortes2042000 As for the Qt/napari stuff, I noticed that you are installing with pip install recOrder-napari[acq] as noted in the README on the main branch. Unfortunately this is a more recent change that has not made into a stable release yet (latest being 0.4.1), so you should have seen a pip warning saying that recOrder-napari does not provide the optional requirement [acq]. I just tested pip install recOrder-napari[acq]==0.4.2rc1 which does include that change with a fresh installation, and the widget loads as expected.

@dbcortes2042000
Copy link

Thanks @ziw-liu ! The second fix took care of the issue for me!

@mattersoflight
Copy link
Member

Thanks @ziw-liu!

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

No branches or pull requests

4 participants