Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 652d44a

Browse filesBrowse files
authored
Merge pull request #27178 from ksunden/3d_missing
Try/except import of Axes3D
2 parents 091746a + 0b8b37e commit 652d44a
Copy full SHA for 652d44a

File tree

Expand file treeCollapse file tree

1 file changed

+14
-2
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+14
-2
lines changed

‎lib/matplotlib/projections/__init__.py

Copy file name to clipboardExpand all lines: lib/matplotlib/projections/__init__.py
+14-2Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,15 @@
5555
from .. import axes, _docstring
5656
from .geo import AitoffAxes, HammerAxes, LambertAxes, MollweideAxes
5757
from .polar import PolarAxes
58-
from mpl_toolkits.mplot3d import Axes3D
58+
59+
try:
60+
from mpl_toolkits.mplot3d import Axes3D
61+
except ImportError:
62+
import warnings
63+
warnings.warn("Unable to import Axes3D. This may be due to multiple versions of "
64+
"Matplotlib being installed (e.g. as a system package and as a pip "
65+
"package). As a result, the 3D projection is not available.")
66+
Axes3D = None
5967

6068

6169
class ProjectionRegistry:
@@ -87,8 +95,12 @@ def get_projection_names(self):
8795
HammerAxes,
8896
LambertAxes,
8997
MollweideAxes,
90-
Axes3D,
9198
)
99+
if Axes3D is not None:
100+
projection_registry.register(Axes3D)
101+
else:
102+
# remove from namespace if not importable
103+
del Axes3D
92104

93105

94106
def register_projection(cls):

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.