question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Inject itself into sys.modules for other PyQt versions

See original GitHub issue

Scenario:

In my app, I from qtpy.QtCore import Qt. I run my app with QT_API=pyqt5, so PyQt5 is preferred, defaulting to PyQt4 if the former is not available. Anyway, PyQt5 is available and my app runs fine.

In some obscure module, or in a stand-alone add-on for my app, I rely on a third-party Python package that imports and works with PyQt4. The import fails. My app breaks.

Use case:

I would like like qtpy to inject itself into sys.modules so that any requests for objects from PyQt4 are resolved, best effort, from qtpy.

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:21 (13 by maintainers)

github_iconTop GitHub Comments

2reactions
kernccommented, Sep 29, 2016

You mean optional in a way such that qtpy library users can decide if they want to enable it, like:

# Somewhere at the beginning of an app
# and before any other PyQt loaded ...
import qtpy
qtpy.enable_compatibility()  # for lack of a better name

Will be happy to!

1reaction
goanpecacommented, May 12, 2017

Lack of response

Read more comments on GitHub >

github_iconTop Results From Across the Web

PyQt modules can't be imported after QtWidgets.QApplication ...
One concrete suggestion: create a test script that simply attempts to execute importlib.import_module(mod_name) before and after creating a ...
Read more >
PyQt5 vs PySide2: What's the difference between the two ...
The key difference in the two versions — in fact the entire reason PySide2 exists — is licensing. PyQt5 is available under a...
Read more >
PyQt5 Tutorial with Examples: Design GUI using PyQt in Python
This tutorial covers basic to advanced stuff like PyQt definitions, features, versions, installation guide, components and widgets, themes, ...
Read more >
Modules and Imports - Python Module of the Week - PyMOTW
sys.modules is a dictionary mapping the names of imported modules to the module object ... package_dir_b) # Reload the module to get the...
Read more >
PyQt5 tutorial 2022: Create a GUI with Python and Qt
PyQt is a library that lets you use the Qt GUI framework from Python. Qt itself is written in C++. By using it...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found