0

I want to run .py file from ipython console in spyder. Script also takes csv file as input. But I got Exception: File src.py not found. How do I run the script from spyder console using relative path?

run src.py input.csv
2
  • 1
    In what directory are you running the command ? You can check this with the command pwd Commented Sep 5, 2022 at 11:52
  • directory of console and file opened in editor are different Commented Sep 5, 2022 at 11:53

1 Answer 1

1

In this format, the path to your file is relative to the command working directory. Therefore, with your command, it looks for src.py in the directory where the console is running (that you can check by running pwd).

Therefore, you should either :

  • input absolute paths
  • open the command to the directory where your files (the script and the csv) are
Sign up to request clarification or add additional context in comments.

3 Comments

thanks! how do i make console automatically switch to the directory of the file opened in editor?
This depends on the configuration of your editor. By default, the terminal opens to the root directory of the opened folder.
To make console automatically switch to the directory of the file opened in editor, goto Preferences->Run and set Default working directory as Directory of the file being executed.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.