I have a python script on another drive:
E:/myscripts/run.py
I am running this from cmd like this:
python
Once I am in the python interpreter, I just do this:
file = "E:/myscripts/run.py"
exec(open(file).read())
It throws an error "No such file or directory: config.txt". This is a file the script opens inside:
open("config.txt")
os.getcwd()
returns C:/Users/me
So it's trying to find the config file there. How can I tell python to look for the related files relative to where the executing script is?
Do I have to specifically change the current directory? Because if I do:
os.chdir("E:/myscripts")
then run my script again, it works. But I was hoping to have some arguments to run the script properly from where it resides.