Python 2.7.2 and Matplotlib problem

This is the place for queries that don't fit in any of the other categories.

Python 2.7.2 and Matplotlib problem

Postby TheIngalator » Fri Oct 25, 2013 3:41 pm

Hi, I'm running Python 2.7.2 on Windows 7 and have installed matplotlib-1.0.1.win32-py2.7 and numpy-1.6.1-win32-superpack-python2.7. I've written the following code to plot a graph...

Code: Select all
import pylab
pylab.plot([0,2,4,6],[0,9,11,2],'r-')
pylab.show()

but keep getting the error message below each time I run the program. The code works fine on a different computer but not on mine and I cannot figure out why! I've uninstalled and reinstalled Python, matplotlib and numpy several times because I previously had Python 3 and Python 2.7.5 and thought perhaps these installations had left files which do not work with matplotlib and numpy - but I still can't get the program to run successfully on my computer. Can anyone help please?

Code: Select all
Traceback (most recent call last):
  File "C:\Programs\wksheet3q6.py", line 1, in <module>
    import pylab
  File "C:\Python27\lib\site-packages\pylab.py", line 1, in <module>
    from matplotlib.pylab import *
  File "C:\Python27\lib\site-packages\matplotlib\pylab.py", line 220, in <module>
    from matplotlib import mpl  # pulls in most modules
  File "C:\Python27\lib\site-packages\matplotlib\mpl.py", line 2, in <module>
    from matplotlib import axis
  File "C:\Python27\lib\site-packages\matplotlib\axis.py", line 13, in <module>
    import matplotlib.scale as mscale
  File "C:\Python27\lib\site-packages\matplotlib\scale.py", line 7, in <module>
    from ticker import NullFormatter, ScalarFormatter, LogFormatterMathtext, Formatter
  File "C:\Python27\lib\site-packages\matplotlib\ticker.py", line 121, in <module>
    import decimal
  File "C:\Python27\lib\decimal.py", line 3715, in <module>
    _numbers.Number.register(Decimal)
AttributeError: 'module' object has no attribute 'Number'
Last edited by Mekire on Fri Oct 25, 2013 3:49 pm, edited 1 time in total.
Reason: Code tags added. First post lock.
TheIngalator
 
Posts: 3
Joined: Fri Oct 25, 2013 3:21 pm

Re: Python 2.7.2 and Matplotlib problem

Postby micseydel » Fri Oct 25, 2013 6:09 pm

Using the install of Python that you have, can you successfully import decimal yourself?
Join the #python-forum IRC channel on irc.freenode.net!
User avatar
micseydel
 
Posts: 1197
Joined: Tue Feb 12, 2013 2:18 am
Location: Mountain View, CA

Re: Python 2.7.2 and Matplotlib problem

Postby TheIngalator » Fri Oct 25, 2013 7:03 pm

micseydel wrote:Using the install of Python that you have, can you successfully import decimal yourself?


Hi, I've tried to import decimal and get the same error message.

Thanks
TheIngalator
 
Posts: 3
Joined: Fri Oct 25, 2013 3:21 pm

Re: Python 2.7.2 and Matplotlib problem

Postby tnknepp » Fri Oct 25, 2013 7:15 pm

I've had similar problems with matplotlib when installed separately. I do not understand why it has worked on some installs and not on others. I concede it is probably something I did wrong, but cannot identify it. I have had great success with using matplotlib when installed with pre-built packages like Anaconda, which also has the benefit of providing numpy/scipy in 64-bit. Just a thought.
Python: 2.7 via Anaconda
Numpy: 1.7
Pandas: 0.11
OS: Windows 7
IDE: Spyder/IPython
User avatar
tnknepp
 
Posts: 119
Joined: Mon Mar 11, 2013 7:41 pm

Re: Python 2.7.2 and Matplotlib problem

Postby micseydel » Fri Oct 25, 2013 9:05 pm

Would you happen to have your own file named "numbers.py"? If so, renaming it will probably solve your problem.
Join the #python-forum IRC channel on irc.freenode.net!
User avatar
micseydel
 
Posts: 1197
Joined: Tue Feb 12, 2013 2:18 am
Location: Mountain View, CA

Re: Python 2.7.2 and Matplotlib problem

Postby TheIngalator » Fri Oct 25, 2013 10:25 pm

micseydel wrote:Would you happen to have your own file named "numbers.py"? If so, renaming it will probably solve your problem.

Problem solved! Thanks for all the suggestions...I did indeed have a file named "numbers.py"! :oops:
TheIngalator
 
Posts: 3
Joined: Fri Oct 25, 2013 3:21 pm

Re: Python 2.7.2 and Matplotlib problem

Postby micseydel » Fri Oct 25, 2013 10:27 pm

Thanks for letting us know that you found the solution, and we're happy to help so you're very welcome!
Join the #python-forum IRC channel on irc.freenode.net!
User avatar
micseydel
 
Posts: 1197
Joined: Tue Feb 12, 2013 2:18 am
Location: Mountain View, CA


Return to General Coding Help

Who is online

Users browsing this forum: anders_w, snippsat and 2 guests