gpt4 book ai didi

python - Matplotlib 无对象 'Use' 或 '__version__'

转载 作者:行者123 更新时间:2023-12-04 16:57:59 29 4
gpt4 key购买 nike

Matplotlib 在 Ubuntu 10.04 LTS 上似乎被破坏了。我不确定几天前会发生什么变化。有人可以提供任何建议来解决我无法从 matplotlib 导入属性的问题吗?谢谢-

我安装(并重新安装)使用:

git clone git://github.com/matplotlib/matplotlib.git
cd matplotlib
python setup.py install

错误:

>>> from matplotlib import *
>>> import matplotlib
>>> matplotlib.use('Agg')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: 'module' object has no attribute 'use'

>>> matplotlib.__version__
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: 'module' object has no attribute '__version__'

最佳答案

如果您将脚本命名为 matplotlib.py 并将其放在列出您的 PYTHONPATH 的目录中,则可能会发生此错误。您的 matplotlib.py 脚本可能掩盖了“真实”包。

测试是否属于这种情况的一种方法是查看 matplotlib.__file__

>>> matplotlib.use('Agg')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: 'module' object has no attribute 'use'
>>> matplotlib.__file__
'/home/unutbu/pybin/matplotlib.py'
>>>

解决方法是将您的 matplotlib.py 重命名为其他名称。

关于python - Matplotlib 无对象 'Use' 或 '__version__',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8650957/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com