3

Matplotlib seems to be broken on Ubuntu 10.04 LTS. I'm not sure what could've changed from a few days ago. Can somebody offer any suggestions to fix the fact that I cannot import attributes from matplotlib? Thanks -

I installed (and re-installed) using:

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

Errors:

>>> 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__'

1 Answer 1

2

This error could happen if you named a script matplotlib.py and have it in a directory listed your PYTHONPATH. Your matplotlib.py script may be masking the "real" package.

One way to test if this is the case is to look at 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'
>>> 

The fix is to rename your matplotlib.py something else.

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks for the answer, however when I do a 'locate matplotlib.py' command, I don't find any files named matplotlib.py. Also, when I do the matplotlib.__file I get the following. Any other suggestions? >>> import matplotlib >>> >>> matplotlib.__file '/usr/lib/pymodules/python2.6/matplotlib/__init__.pyc'

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.