[Tutor] Problems with matplotlib

Peter Otten __peter__ at web.de
Sat Feb 18 19:32:40 EST 2017


Pooja Bhalode wrote:

> Hi,
> 
> I am trying to create a simple normal plot. But I am getting some
> errors which I am not able to understand. Would be a great help if someone
> can guide me to what I am doing wrong.
> 
> Thankyou so much.
> Here is the code:
> 
> # import matplotlib.pyplot as plt
> from matplotlib import pyplot as plt
> (Here, I have tried both these import statements, but both give me the
> same error.)
> 
> x = [1,2,4,5,6,8,9,10]
> y = [6,7,8,9,10,11,12,14]
> plt.figure()
> plt.plot(x,y)
> plt.show()
> 
> Error:
> 
> /Users/poojabhalode/.bash_profile: line 1: .bashrc: No such file or
> directory
> Traceback (most recent call last):
>   File "/Users/poojabhalode/Google Drive/GUI Python/matplot.py", line 3,
>   in
> <module>
>     from matplotlib import pyplot as plt
>   File
> 
"/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/matplotlib/__init__.py",
> line 123, in <module>
>     import pyparsing
>   File
> 
"/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pyparsing.py",
> line 3260, in <module>
>     _reBracketExpr = Literal("[") + Optional("^").setResultsName("negate")
> + Group( OneOrMore( _charRange | _singleChar ) ).setResultsName("body") +
> "]"
>   File
> 
"/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pyparsing.py",
> line 775, in setResultsName
>     newself = self.copy()
>   File
> 
"/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pyparsing.py",
> line 749, in copy
>     cpy = copy.copy( self )
> AttributeError: 'module' object has no attribute 'copy'
> [Finished in 2.4s with exit code 1]
> [shell_cmd: python -u "/Users/poojabhalode/Google Drive/GUI
> Python/matplot.py"]
> [dir: /Users/poojabhalode/Google Drive/GUI Python]
> [path: /usr/bin:/bin:/usr/sbin:/sbin]
> 
> I am running this on the inbuilt python in Mac10.12
> When I try running the same in terminal it works, but here it is not able
> to compile.
> Please let me know.

You have a file copy.py, probably written by yourself, that shades the copy 
module in Python's standard library. To locate this module (if it is not in 
the current working directory) add the lines

import copy
print copy.__file__

If I'm guessing right everything should work after you have removed the pyc-
file and renamed the corresponding copy.py.



More information about the Tutor mailing list