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

[BUG] If PyQt5 is in your environment, recOrder will use it (causing GUI checkboxes to fail) #409

Closed
talonchandler opened this issue Aug 16, 2023 · 5 comments · Fixed by #420

Comments

@talonchandler
Copy link
Collaborator

@edyoshikun and I tested a pip install -e . installation into an existing environment and we ran into Qt bugs.

We found that the pip install -e . did not uninstall PyQt5, so recOrder was using that.

@ziw-liu is there a way to ensure that a package is not in an environment? If not, we should do fresh conda environments on all of our computers and make sure that PyQt5 is not in our environments.

@ziw-liu
Copy link
Contributor

ziw-liu commented Aug 16, 2023

is there a way to ensure that a package is not in an environment?

Easiest way to ensure:

try:
    import PyQt5
    raise RuntimeError(...)
except ImportError:
    try:
        import PySide2
        raise RuntimeError(...)
    except ImportError:
        pass  # all good

However I'm not aware of an automatic way to uninstall the old one through dependency management, since they are different packages (on purpose).

@edyoshikun
Copy link
Contributor

edyoshikun commented Aug 16, 2023

Can we do something like ...

#logic to list the packages we don't want 


packages_to_uninstall = ['package_to_uninstall1', 'package_to_uninstall2']
for package in packages_to_uninstall:
    subprocess.run(['pip', 'uninstall', package, '-y'])

maybe this is not ideal for users if they have other stuff that depends on pyqt5..

@ziw-liu
Copy link
Contributor

ziw-liu commented Aug 17, 2023

Can we do something like ...

#logic to list the packages we don't want 


packages_to_uninstall = ['package_to_uninstall1', 'package_to_uninstall2']
for package in packages_to_uninstall:
    subprocess.run(['pip', 'uninstall', package, '-y'])

maybe this is not ideal for users if they have other stuff that depends on pyqt5..

Then you would also need to account for the whole pip/conda/mamba/poetry/venv/pyenv/apt/pacman/yum/... situation

@talonchandler
Copy link
Collaborator Author

@ziw-liu would that snippet need to appear every time we import qtpy?

From qtpy's documentation "If several of these packages are found, PyQt5 is used by default unless you set the QT_API environment variable."

Do you think this one-line addition would work? Where should this line live?
import os os.environ["QT_API"] = "pyqt6"

@ziw-liu
Copy link
Contributor

ziw-liu commented Aug 18, 2023

Do you think this one-line addition would work? Where should this line live?

Not sure if it will work everywhere (especially Windows) and we need to test this. But if it works, it could be added to the top-level __init__.py so anything importing from recOrder will evaluate that line.

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

Successfully merging a pull request may close this issue.

3 participants