Reputation: 359
I have this line in my bat file:
C:\Python26\python.exe C:\myPythonDirectory.py
But it fails giving the error: can't open file [Errno2] no such file or directory.
Could it be giving an error because there is a space in one of the folder names in my python directory?
Upvotes: 2
Views: 701
Reputation: 1
If there are spaces in the names of the directories you need to use the below code. For example, the name of the directory and the path is "D:\My New Bot\main.py" . as there is a gap between the words , python recognises only the first word and tries to find path as "D:\My" which does not exist. Please use the below code :
path = r"D:\My New Bot\main.py"
This will work.
Upvotes: 0
Reputation: 44436
Absolutely. If there's a space in the path, you need to put the whole path in double quotes.
Upvotes: 2