python script

Hello,

my problem is described very quickly:
The package is installed. In the interpreter the 'import matplotlib' does not throw an error. On the other hand I tried to use matplotlib in a python script and here the very same command provokes the following error message:

Traceback (most recent call last):
   File "./account3.py", line 13, in <module>
     import matplotlib
ImportError: No module named matplotlib

I would be greatful for any help/explanaiton.
Cheers,
Felix

$ uname -aDarwin mac-screening-1 9.8.0 Darwin Kernel Version 9.8.0: Wed Jul 15 16:55:01 PDT 2009; root:xnu-1228.15.4~1/RELEASE_I386 i386

$ python
Python 2.5.4 (r254:67917, Dec 23 2008, 14:57:27)
[GCC 4.0.1 (Apple Computer, Inc. build 5363)] on darwin

$ python -c 'import matplotlib; print matplotlib.__version__, matplotlib.__file__'
0.99.0 /Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/matplotlib/__init__.pyc

The Package was downloaded from the link:
http://sourceforge.net/projects/matplotlib/files/matplotlib/matplotlib-0.99.1/matplotlib-0.99.1.1-py2.5-macosx10.5.dmg/download

felix meyenhofer wrote:

The package is installed. In the interpreter the 'import matplotlib' does not throw an error. On the other hand I tried to use matplotlib in a python script and here the very same command provokes the following error message:

how are you running that script? I supect you are getting a different python.

try:

$ python TheNameOfTheScript

that should get you the same python as you get typig "python"

If you run the script directly:

$ ./TheNameOfTheScript

it will use the #! line at the top to tell it where to find python. If that line says"

#!/usr/bin/python

you'll probably get a different one. the usual convention is:

#!/usr/bin/env python

which should get you the same one that you get when you start python at the command line.

a few things to try to test all this:

$ which python

$ python -c "import sys; print sys.path"
$ python -c "import sys; print sys.executable"

putting import sys" and "print sys.path" or "print sys.executable" at the top of your troublesome script.

HTH,

-Chris

···

Traceback (most recent call last):
   File "./account3.py", line 13, in <module>
     import matplotlib
ImportError: No module named matplotlib

I would be greatful for any help/explanaiton.
Cheers,
Felix

$ uname -aDarwin mac-screening-1 9.8.0 Darwin Kernel Version 9.8.0: Wed Jul 15 16:55:01 PDT 2009; root:xnu-1228.15.4~1/RELEASE_I386 i386

$ python
Python 2.5.4 (r254:67917, Dec 23 2008, 14:57:27)
[GCC 4.0.1 (Apple Computer, Inc. build 5363)] on darwin

$ python -c 'import matplotlib; print matplotlib.__version__, matplotlib.__file__'
0.99.0 /Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/ site-packages/matplotlib/__init__.pyc

The Package was downloaded from the link:
http://sourceforge.net/projects/matplotlib/files/matplotlib/matplotlib-0.99.1/matplotlib-0.99.1.1-py2.5-macosx10.5.dmg/download

------------------------------------------------------------------------------
Come build with us! The BlackBerry&reg; Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay ahead of the curve. Join us from November 9&#45;12, 2009. Register now&#33;
http://p.sf.net/sfu/devconf
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

--
Christopher Barker, Ph.D.
Oceanographer

Emergency Response Division
NOAA/NOS/OR&R (206) 526-6959 voice
7600 Sand Point Way NE (206) 526-6329 fax
Seattle, WA 98115 (206) 526-6317 main reception

Chris.Barker@...259...