Closed
Description
Bug report
Bug summary
When installing PyQt5, PyQt5_sip is also installed under PyQt5. Therefore, when uninstalling PyQt5 matplotlib gets fooled by code defaulting to PySide2 if PyQt5 is not present.
Code for reproduction
Prior to run the code one should perform the commands below
pip install PyQt5
pip install PySide2
pip uninstall PyQt5
Then the code below fails.
import sys
try:
from PyQt5.QtWidgets import QApplication
print("Using PyQt5")
except ImportError:
print("PyQt5 is in sys.modules = %s" % ("PyQt5" in sys.modules))
from PySide2.QtWidgets import QApplication
print("Using PySide2")
from matplotlib.backends.backend_qt5agg import FigureCanvasQTAgg as FigureCanvas
Actual outcome
Expected outcome
No crash should be there when PySide2 is installed.
The test in qt_compat.py should be for PyQt5.QtCore being in sys.modules instead of for PyQt5 in sys.modules
Matplotlib version
- Operating system: Windows
- Matplotlib version: 3.0.3 (from PyPI) and 3.1.0rc2 (from Gohlke)
- Matplotlib backend (
print(matplotlib.get_backend())
): PySide2, PyQt5 - Python version: 3.7