-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Try/except import of Axes3D #27178
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
Try/except import of Axes3D #27178
Conversation
On some installs, the `mpl_toolkits` namespace package gets an old version which uses deprecated (And removed) code from the main library. On such the import of Axes3D will error with an `ImportError`. This prevents users from using any of `matplotlib`, since it is imported unconditionally by default. This just try/excepts the imports (and adjusts the registration code accordingly) to allow users to continue using matplotlib (though not 3D and possibly not other mpl_toolkits) even with older installs occluding the mpl_toolkits.
Do we want to add a warning somewhere in here? (Currently just silently ignores that the import didn't work) I'm 50/50 on it currently: There is something wrong with the install, but most users are unlikely to be negatively affected by it, and getting a warning unrelated to what you are doing seems unhelpful. Perhaps we could put code in the retrieval that looks for the |
I think we should warn. I'm inclined to let people know that their installations are messed up (or I may just be cranky today after two h5py issues that boiled down to "broken installation"). |
I did not use |
Co-authored-by: Elliott Sales de Andrade <quantum.analyst@gmail.com>
…178-on-v3.8.x Backport PR #27178 on branch v3.8.x (Try/except import of Axes3D)
Needed for the same reasons as matplotlib#27178 (Namely that we should not be failing on import just because mpl_toolkits is broken), but mpl 3.6 presents with an AttributeError rather than ImportError See discussion in matplotlib#26827 and matplotlib#27289 Just expanded liberally in case there are other presentations we have not seen
Needed for the same reasons as matplotlib#27178 (Namely that we should not be failing on import just because mpl_toolkits is broken), but mpl 3.6 presents with an AttributeError rather than ImportError See discussion in matplotlib#26827 and matplotlib#27289 Just expanded liberally in case there are other presentations we have not seen
PR summary
On some installs, the
mpl_toolkits
namespace package gets an oldversion which uses deprecated (And removed) code from the main library.
On such the import of Axes3D will error with an
ImportError
.This prevents users from using any of
matplotlib
, since it is importedunconditionally by default.
This just try/excepts the imports (and adjusts the registration code
accordingly) to allow users to continue using matplotlib (though not 3D
and possibly not other mpl_toolkits) even with older installs occluding
the mpl_toolkits.
Addresses at least the most pressing part of #26827
(Not quite sure we want to close that or not)
PR checklist