Search code examples
pythonipythonspyder

run script from spyder console using relative path


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

Solution

  • 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