Import matplotlib.pyplot fails on windows XP

Hello,

I’ve installed the following Python packages on a Windows XP machine:

Python 2.6.5

Python 2.6 numpy-1.4.1

Python 2.6 matplotlib-0.99.3 [installer - matplotlib-0.99.3.win32-py2.6]

Python and Numpy work correctly. Matplotlib also works and as a test I tried successfully the following on the python interpretor:

from matplotlib.pyplot import *
plot([1,2,3])
show()

A graph then appears and thus so far so good.

However, when I try to run a certain python script, a problem occurs when importing from matplotlib:

Traceback (most recent
call last):

File
“C:\Pythoncode\Games\Bridge_war_2\unitload2.py”, line 2, in

from matplotlib.pyplot
import plot, ylabel,xlabel, show

File
“C:\Python26\lib\site-packages\matplotlib\pyplot.py”, line
78, in

new_figure_manager,
draw_if_interactive, show = pylab_setup()

File
“C:\Python26\lib\site-packages\matplotlib\backends_init_.py”,
line 25, in pylab_setup

globals(),locals(),[backend_name])

File
“C:\Python26\lib\site-packages\matplotlib\backends\backend_tkagg.py”,
line 7, in

import Tkinter as Tk,
FileDialog

File
“C:\Python26\lib\lib-tk\FileDialog.py”, line 12, in

from Dialog import
Dialog

File
“C:\Pythoncode\Games\Bridge_war_2\Dialog.py”, line 2, in

import wx

ImportError: No module
named wx

And then no graph appears.

The same script works fine on my Linux computers. On the unitload2.py script, the following is imported:

from numpy import array, append, …
from numpy.linalg import solve

No further modules are imported. Once I’ve ran the unitload2.py script, that session of the python interpretor produces the same error when I try a test plot again.

Regards

Alex

···

Get a new e-mail account with Hotmail - Free. Sign-up now.

The error is that your Windows XP box does not have the wxPython module installed for Windows.

http://www.wxpython.org/download.php

I hope that helps,

Ben Root

···

On Sat, Jul 24, 2010 at 4:57 AM, eck naysmith <eckeroo8@…32…> wrote:

Hello,

I’ve installed the following Python packages on a Windows XP machine:

Python 2.6.5

Python 2.6 numpy-1.4.1

Python 2.6 matplotlib-0.99.3 [installer - matplotlib-0.99.3.win32-py2.6]

Python and Numpy work correctly. Matplotlib also works and as a test I tried successfully the following on the python interpretor:

from matplotlib.pyplot import *
plot([1,2,3])
show()

A graph then appears and thus so far so good.

However, when I try to run a certain python script, a problem occurs when importing from matplotlib:

Traceback (most recent
call last):

File
“C:\Pythoncode\Games\Bridge_war_2\unitload2.py”, line 2, in

from matplotlib.pyplot
import plot, ylabel,xlabel, show

File
“C:\Python26\lib\site-packages\matplotlib\pyplot.py”, line
78, in

new_figure_manager,
draw_if_interactive, show = pylab_setup()

File
“C:\Python26\lib\site-packages\matplotlib\backends_init_.py”,
line 25, in pylab_setup

globals(),locals(),[backend_name])

File
“C:\Python26\lib\site-packages\matplotlib\backends\backend_tkagg.py”,
line 7, in

import Tkinter as Tk,
FileDialog

File
“C:\Python26\lib\lib-tk\FileDialog.py”, line 12, in

from Dialog import
Dialog

File
“C:\Pythoncode\Games\Bridge_war_2\Dialog.py”, line 2, in

import wx

ImportError: No module
named wx

Hello,

I've installed the following Python packages on a Windows XP machine:

Python 2.6.5

Python 2.6 numpy-1.4.1

Python 2.6 matplotlib-0.99.3 [installer - matplotlib-0.99.3.win32-py2.6]

Python and Numpy work correctly. Matplotlib also works and as a test I tried successfully the following on the python interpretor:

from matplotlib.pyplot import *
plot([1,2,3])
show()

A graph then appears and thus so far so good.

However, when I try to run a certain python script, a problem occurs when importing from matplotlib:

Traceback (most recent
call last):
  File
"C:\Pythoncode\Games\Bridge_war_2\unitload2.py", line 2, in
<module>
    from matplotlib.pyplot
import plot, ylabel,xlabel, show
  File
"C:\Python26\lib\site-packages\matplotlib\pyplot.py", line
78, in <module>
    new_figure_manager,
draw_if_interactive, show = pylab_setup()
  File
"C:\Python26\lib\site-packages\matplotlib\backends\__init__.py",
line 25, in pylab_setup
    globals(),locals(),[backend_name])
  File
"C:\Python26\lib\site-packages\matplotlib\backends\backend_tkagg.py",
line 7, in <module>
    import Tkinter as Tk,
FileDialog
  File
"C:\Python26\lib\lib-tk\FileDialog.py", line 12, in
<module>
    from Dialog import
Dialog
  File
"C:\Pythoncode\Games\Bridge_war_2\Dialog.py", line 2, in
<module>
    import wx
ImportError: No module
named wx

The error is that your Windows XP box does not have the wxPython module installed for Windows.

http://www.wxpython.org/download.php

I hope that helps,

Ben Root

No calls are made anywhere for wxPython so I don't know why it is seeking it. But when I installed wxPython anyway just to see what would happen, the traceback then ends at the penultimate line shown above i.e

"File
"C:\Python26\lib\lib-tk\FileDialog.py", line 12, in
<module>
    from Dialog import
Dialog"
On the Traceback, each line beggining with 'File "C:\Python26......." is a seperate error. The most significant error is the first one:
'Traceback (most recent
call last):
  File
"C:\Pythoncode\Games\Bridge_war_2\unitload2.py", line 2, in
<module>
    from matplotlib.pyplot
import plot, ylabel,xlabel, show'
I suspected the problems were arising from the use of the statement 'from numpy import foobar' overwriting some of the names used by matplotlib, so I changed the import statement to 'import numpy' to avoid any potential namespace clash and adjusted the code accordingly. This does nothing and the exact same Traceback error messages occur.
Regards

Alex

···

From: ben.root@...1304...
Date: Mon, 26 Jul 2010 09:56:27 -0500
Subject: Re: [Matplotlib-users] Import matplotlib.pyplot fails on windows XP
To: eckeroo8@...32...
CC: matplotlib-users@lists.sourceforge.net
On Sat, Jul 24, 2010 at 4:57 AM, eck naysmith <eckeroo8@...32...> wrote:

_________________________________________________________________
http://clk.atdmt.com/UKM/go/195013117/direct/01/
We want to hear all your funny, exciting and crazy Hotmail stories. Tell us now

Problem solved.

When I set up python on the Windows machine, I simply copied over the directories and everything in them from my Linux machine, including all of the python bytecode *.pyc files. Trying to run a script with those *.pyc files present was causing the problem as they were compiled on my Linux machine originally.

The matplotlib call works fine when I move the scripts to a clean folder.

Thanks

Alex

···

From: ben.root@…1304…
Date: Mon, 26 Jul 2010 09:56:27 -0500
Subject: Re: [Matplotlib-users] Import matplotlib.pyplot fails on windows XP
To: eckeroo8@…32…
CC: matplotlib-users@…1735…sourceforge.net

On Sat, Jul 24, 2010 at 4:57 AM, eck naysmith <eckeroo8@…32…> wrote:

Hello,

I’ve installed the following Python packages on a Windows XP machine:

Python 2.6.5

Python 2.6 numpy-1.4.1

Python 2.6 matplotlib-0.99.3 [installer - matplotlib-0.99.3.win32-py2.6]

Python and Numpy work correctly. Matplotlib also works and as a test I tried successfully the following on the python interpretor:

from matplotlib.pyplot import *
plot([1,2,3])
show()

A graph then appears and thus so far so good.

However, when I try to run a certain python script, a problem occurs when importing from matplotlib:

Traceback (most recent
call last):

File
“C:\Pythoncode\Games\Bridge_war_2\unitload2.py”, line 2, in

from matplotlib.pyplot
import plot, ylabel,xlabel, show

File
“C:\Python26\lib\site-packages\matplotlib\pyplot.py”, line
78, in

new_figure_manager,
draw_if_interactive, show = pylab_setup()

File
“C:\Python26\lib\site-packages\matplotlib\backends_init_.py”,
line 25, in pylab_setup

globals(),locals(),[backend_name])

File
“C:\Python26\lib\site-packages\matplotlib\backends\backend_tkagg.py”,
line 7, in

import Tkinter as Tk,
FileDialog

File
“C:\Python26\lib\lib-tk\FileDialog.py”, line 12, in

from Dialog import
Dialog

File
“C:\Pythoncode\Games\Bridge_war_2\Dialog.py”, line 2, in

import wx

ImportError: No module
named wx

The error is that your Windows XP box does not have the wxPython module installed for Windows.

http://www.wxpython.org/download.php

I hope that helps,

Ben Root


Get a free e-mail account with Hotmail. Sign-up now.