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/