Python SciPy call from terminal failing
Question: I am trying to call the following Python script from the Ubuntu terminal using
the standard

`python rosen.py`

but it fails. I can hit `F5` in idle and it works fine but it fails when
called from the terminal. The code for `rosen.py` is as follows:

    
    
    from scipy.optimize import fmin
    
    def rosen(x):
        b=sum(100.0*(x[1:]-x[:-1]**2.0)**2.0 + (1-x[:-1])**2.0)
        print b
        return b
    
    x0 = [1.3, 0.7, 0.8, 1.9, 1.2]
    xopt = fmin(rosen, x0, xtol=1e-8)
    print xopt
    

again, when run in idle it works fine, but when called from the terminal it
says that scipy doesn't exist...

I can run the following numpy code from the terminal or idle and it works
fine:

    
    
    import numpy as np
    a=np.sin(1)
    print a
    

It will print in either the terminal window or idle window depending where it
was called.

Basically, how can I get the rosen.py to import SciPy and run when called from
the Ubuntu terminal??

Thank you very much for the help.


Answer: Do you have

    
    
    #!/usr/bin/python
    

at the top of your file to identify the location of the python interpreter?
And made your script executable with

    
    
    chmod +x rosen.py
    

Then either command works for me under Ubuntu:

    
    
    ./rosen.py 
    

or

    
    
    python rosen.py 
    

(The `chmod` is optional if you want to be able to run the script w/o typing
`python` first on the command line. `python rosen.py` will work w/o the
`chmod`)

And as you are already importing scipy in your script, so I am not sure I
understand that part of the question.

