[SciPy-user] 'crashing' python

Peter Wang pwang at enthought.com
Sun Jul 31 16:04:06 CDT 2005


Victor Reijs wrote ..
> My knowledge is growing, but it seems I still am not able to run the
> scipytest.py (renamed for PSP to scipytest.PspScript). So I must be
> doing something wrong...

Hi Victor,

It seems to me that if you can get your script running in IDLE but not from PSP's RunScript, then there is a problem with the PYTHONPATH.  This may be repeated info, but the PYTHONPATH environment variable defines what directories the python interpreter searches for modules.  If PSP ships with its own version of Python 2.2, they probably modified the installation a bit so that it ignores the system PYTHONPATH variable.  If this is the case, then you have to modify the path inside your script.  You can do this by appending to sys.path.

If you did a normal installation of Enthon/SciPy, then the scipy module resides in your c:\python23\lib\site-packages directory.  Consequently, you need to add this to the python path of your script after it gets launched by the RunScript hook, but before it tries to import scipy:

import sys
sys.path.append("c:/python23/lib/site-packages")
from scipy import *
from scipy.optimize import fmin

Note that I used forward slashes instead of backslashes; Windows doesn't care.  If you choose to use backslashes, you should be aware that python will treat backslashes as escape characters, so you need to do "c:\\path\\to\\directory".  (There are also some other ways to get around this.)

Give that a go and let us know if you still have problems.

-Peter


More information about the SciPy-user mailing list