On 12/19/2014 01:38 AM, Lei wrote:
Hi Arian,

thanks for your reply!!

But it is still not working for me. I did the following:
1. Launch Spyder
2. In "IPython console" write
     In[1]: import interest
     In[2]: !python interest.py A=10 p=5 n=730
python: can't open file 'interest.py': [Errno 2] No such file or directory

Is it because the interest.py file is not in the recognized directory of
Sypder? I have already added its path via "Tools" --> "PYTHONPATH manager".

Yes, Python is not finding the file. It starts by looking in the directory it is started in and then goes down the PYTHONPATH.

Did you restart Spyder after making the path change?

Another option is to change the Spyder working directory using the directory changer at the right top of the program. FYI, you will need to restart the IPython or Python console for the change to be seen

Another question, why do I need to use "!python" instead of "python"?
According to the website
https://docs.python.org/3/tutorial/stdlib.html#command-line-arguments

That is based on starting the program from the OS shell command line. You are trying to start it from inside IPython which is a Python interpreter. The ! is some IPython 'magic' that allows you run programs from the OS command line. So !python is telling IPython to go the the OS command line and run python interest.py ...


If you do not want to do that import interest.py like:

import interest

Again it will need to be on the PYTHON PATH.
Then you can use the functions directly. This will require looking at the code to see what it is doing.


It just says
python demo.py one two three

Thanks again!




--
Adrian Klaver
[email protected]

--
You received this message because you are subscribed to the Google Groups 
"spyder" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/spyderlib.
For more options, visit https://groups.google.com/d/optout.

Reply via email to