调用matplotlib时发生这种问题:
问题相关代码,请勿粘贴截图
import matplotlib.pyplot as plt
直接在调用时报错:
Traceback (most recent call last):
File "XXX.py", line 3, in <module>
from matplotlib import pyplot as plt
File "C:\Program Files\Python39\lib\matplotlib\pyplot.py", line 44, in <module>
from matplotlib.figure import Figure, figaspect
File "C:\Program Files\Python39\lib\matplotlib\figure.py", line 24, in <module>
from matplotlib import docstring, projections
File "C:\Program Files\Python39\lib\matplotlib\projections\__init__.py", line 4, in <module>
from mpl_toolkits.mplot3d import Axes3D
File "XXX\lib\site-packages\mpl_toolkits\mplot3d\__init__.py", line 1, in <module>
from .axes3d import Axes3D
File "XXX\lib\site-packages\mpl_toolkits\mplot3d\axes3d.py", line 47, in <module>
class Axes3D(Axes):
File "XXX\lib\site-packages\mpl_toolkits\mplot3d\axes3d.py", line 54, in Axes3D
Axes._shared_axes["z"] = cbook.Grouper()
AttributeError: type object 'Axes' has no attribute '_shared_axes'
(XXX
中包含隐私信息,所以就用XXX
代替,但是XXX\lib
已经加到sys.path
里了)