[Tutor] Problems with matplotlib
Peter Otten
__peter__ at web.de
Sat Mar 4 02:30:32 EST 2017
Jason Snyder wrote:
> I installed the python module matplotlib on a computer and when I try to
> run a program with the commands:
>
> import matplotlib.pyplot as plt I get the following errors:
>
> Traceback (most recent call last):
> File "new.py", line 1, in <module>
> import matplotlib
> File "/usr/lib64/python2.7/site-packages/matplotlib/__init__.py", line
> 151, in <module>
> from matplotlib.rcsetup import (defaultParams,
> File "/usr/lib64/python2.7/site-packages/matplotlib/rcsetup.py", line
> 20,
> in <module>
> from matplotlib.colors import is_color_like
> File "/usr/lib64/python2.7/site-packages/matplotlib/colors.py", line 54,
> in <module>
> import matplotlib.cbook as cbook
> File "/usr/lib64/python2.7/site-packages/matplotlib/cbook.py", line 32,
> in <module>
> import new
> File "/home/www/html/auroratest/new.py", line 8, in <module>
> plt.scatter(x,y)
> NameError: name 'plt' is not defined
>
> when I try to use something like import matplotlib.image as image I get
> the following errors:
>
> Traceback (most recent call last):
> File "new.py", line 1, in <module>
> import matplotlib.image as image
> File "/usr/lib64/python2.7/site-packages/matplotlib/__init__.py", line
> 151, in <module>
> from matplotlib.rcsetup import (defaultParams,
> File "/usr/lib64/python2.7/site-packages/matplotlib/rcsetup.py", line
> 20,
> in <module>
> from matplotlib.colors import is_color_like
> File "/usr/lib64/python2.7/site-packages/matplotlib/colors.py", line 54,
> in <module>
> import matplotlib.cbook as cbook
> File "/usr/lib64/python2.7/site-packages/matplotlib/cbook.py", line 32,
> in <module>
> import new
This looks like a name clash. There is a module called "new" in Python's
standard library, and matplotlib is trying to install that. Instead your own
> File "/home/www/html/auroratest/new.py", line 1, in <module>
is found. Once you rename your new.py to something else (and remove the
corresponding new.pyc) things should start to work again.
> import matplotlib.image as image
> File "/usr/lib64/python2.7/site-packages/matplotlib/image.py", line 13,
> in <module>
> from matplotlib import rcParams
> ImportError: cannot import name rcParams
>
> What is causing these errors and what specific things do I need to do to
> resolve this. I need this explained clearly in a step by step way.
>
> Thanks,
>
> Jason
>
More information about the Tutor
mailing list