Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Matplotlib no object 'Use' or '__version__'

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__'
like image 952
PhilBot Avatar asked Aug 20 '26 04:08

PhilBot


1 Answers

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.

like image 141
unutbu Avatar answered Aug 21 '26 18:08

unutbu



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!