我刚开始使用MatPlotLib,我试图打印出版本号
这是我的密码:
import matplotlib
print(matplotlib.__version_)
但是,当我运行它时,我得到一个错误:
Traceback (most recent call last):
File "c:/Users/Atharv 2020/Pyfiles/matplotlib.py", line 1, in <module>
import matplotlib
File "c:\Users\Atharv 2020\Pyfiles\matplotlib.py", line 2, in <module>
print(matplotlib.__version_)
AttributeError: partially initialized module 'matplotlib' has no attribute '__version_' (most likely due to a circular import)
你能帮我吗
根据@dm2上面的评论,错误在于将代码写入一个名为
matplotlib.py
的文件中。当我导入matplotlib
时,我实际上导入了matplotlib.py
(文件)而不是matplotlib
(库)。因此,重命名文件将解决此问题我还意识到“version”后面只有一个下划线
谢谢你,@dm2
相关问题 更多 >
编程相关推荐