-
-
Notifications
You must be signed in to change notification settings - Fork 8k
Open
Description
Bug summary
As of matplotlib 3.10.5, deleting the module on the fly and then reimporting it does not work anymore. This used to work in 3.10.3.
Code for reproduction
#!/usr/bin/env python
import sys
import matplotlib.pyplot as plt
package_names = ["matplotlib"]
for package in package_names:
loaded_package_modules = [key for key, value in sys.modules.items() if package in str(value)]
for key in loaded_package_modules:
del sys.modules[key]
import matplotlib.pyplot as plt
Actual outcome
Traceback (most recent call last):
File "/home/neutronst4r/3Dplot_test/./mp_import_test2.py", line 12, in <module>
import matplotlib.pyplot as plt
File "/home/neutronst4r/[redacted]/env/lib/python3.13/site-packages/matplotlib/__init__.py", line 161, in <module>
from . import _api, _version, cbook, _docstring, rcsetup
File "/home/neutronst4r/[redacted]/env/lib/python3.13/site-packages/matplotlib/rcsetup.py", line 28, in <module>
from matplotlib.colors import Colormap, is_color_like
File "/home/neutronst4r/[redacted]/env/lib/python3.13/site-packages/matplotlib/colors.py", line 57, in <module>
from matplotlib import _api, _cm, cbook, scale, _image
ImportError: generic_type: type "_InterpolationType" is already registered!
Expected outcome
import should work without error
Additional information
error is fixed by switching to matplotlib 3.10.3
Operating system
Arch Linux using virtual environment
Matplotlib Version
3.10.5
Matplotlib Backend
No response
Python version
3.13.5
Jupyter version
No response
Installation
pip
Metadata
Metadata
Assignees
Labels
No labels