AttributeError:部分初始化的模块“matplotlib”没有属性“\uuuu version”(很可能是由于循环导入)

2024-10-02 12:27:53 发布

您现在位置:Python中文网/ 问答频道 /正文

我刚开始使用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)

你能帮我吗


Tags: inpyimportmostmatplotlibversion版本号line
1条回答
网友
1楼 · 发布于 2024-10-02 12:27:53

根据@dm2上面的评论,错误在于将代码写入一个名为matplotlib.py的文件中。当我导入matplotlib时,我实际上导入了matplotlib.py(文件)而不是matplotlib(库)。因此,重命名文件将解决此问题

我还意识到“version”后面只有一个下划线

谢谢你,@dm2

相关问题 更多 >

    热门问题