[SciPy-user] 'crashing' python

Brandon DuRette bdurette at enthought.com
Sun Jul 31 10:09:27 CDT 2005

Hi Victor,

> That looks to be working and I can repeat it, which is good;-)
> But why is this 'from scipy.optimize import fmin' needed even if I did 
> 'from scipy import *' before that?
> If I read in the scipy documentation, I thought, that 'from scipy 
> import *' would be enough.

I think your confusion is probably with the word 'package'.  The code 
'from scipy import *' imports everything from the 'scipy' package.  But 
that's not 'all of scipy'.  Scipy has subpackages, such as optimize, 
that are not imported as part of the main scipy package.  For more on 
Python packages, check here:


> Just to let you know, I am a novice to python, so perhaps I 
> misunderstand the basics of it! 

No worries.  We were all novices at one point. ;-)

> I just am learning it because it is needed to do scripting in Paint 
> Shop Pro (PSP). PSP8 has Python 2.2 in it, but not the optimization 
> function fmin (which I need for optimizing colors in pictures: 
> http://www.iol.ie/~geniet/eng/IFRAOcoloropt.htm )
>>    * Does sys.path refer to the correct path (i.e., where you installed
>>      Enthon)?
> I can't run the python code from the normal python GUI (IDLE). I get 
> this:
> ">>> ================================ RESTART 
> ================================
> >>>
> Traceback (most recent call last):
>   File "C:\Documents and Settings\vreijs\My Documents\My PSP8 
> Files\Scripts-Trusted\scipy.py", line 1, in -toplevel-
>     from scipy import *
>   File "C:\Documents and Settings\vreijs\My Documents\My PSP8 
> Files\Scripts-Trusted\scipy.py", line 2, in -toplevel-
>     from scipy.optimize import fmin
> ImportError: No module named optimize
> >>> "

Ah...  I think I know what the problem is.  Rename scipy.py to something 
else.  By naming it scipy.py, you have shadowed the scipy package (and 
also the scipy.optimize subpackage). 

> Aoso 'print sys.path' gives no results:
> ">>> print sys.path
> Traceback (most recent call last):
>   File "<pyshell#0>", line 1, in -toplevel-
>     print sys.path
> NameError: name 'sys' is not defined
> >>> "

Yeah.  I forgot to mention, you need to import sys first.  'import sys; 
print sys.path'.  But that may be irrelevant at this point.


More information about the SciPy-user mailing list