4

I have written a .py file using Eclipse. I want to run that file in command prompt. How do I go about that? I'm running it on Windows.

I tried python D:\Python Work/class/src/hello.py The error I received was python: can't open file 'D:\Python':[Errno 2] No such file or directory. Also 'D:\Python' is not the entire address that I had specified.

Python was already been added to the PATH. I tried doing cd[file directory] and then python file.py but that gave me the same error

Thanks

Asher
  • 791
  • 2
  • 7
  • 19

1 Answers1

13

Assuming you are running on windows - either:

python "D:\\Folder name\\Project name\\src\\module name.py"

Or:

python "D:/Folder name/Project name/src/module name.py"

Your choice basically.

The rules for windows file names are:

Back slashes, \ must be escaped by doubling to \\ spaces must be inside of double quotes "like this" quotes and few others need to be escaped as well and the extension does matter so give it.

Steve Barnes
  • 24,968
  • 6
  • 54
  • 63