cannot run python script file using windows prompt

前端 未结 4 2036
既然无缘
既然无缘 2021-01-22 00:05

I am trying to run a python script from the windows command prompt, but I receive the following error message:

\"python: can\'t open file \'pacman.py\': [Errno 2] No

相关标签:
4条回答
  • 2021-01-22 00:48

    python "C:\Users\Chris\Dropbox\edX\CS188x\search\pacman.py"

    or

    cd C:\Users\Chris\Dropbox\edX\CS188x\search\
    "c:\prorgam files (x86)\python27\python" pacman.py
    
    0 讨论(0)
  • 2021-01-22 00:52

    SOLVED! So the comments were right in that I had to change the directory to the location of the file, but what was missing was that I had to edit the system environment variable PATH to include the location of python.exe, which is my case was C:\program files (x86)\python27 but for most people is just C:\python27. Thanks everyone for all your help!

    0 讨论(0)
  • 2021-01-22 00:58

    did you try running the script from its directory?

    i can only guess, but maybe its some issue with the file being located inside your dropbox folder...

    0 讨论(0)
  • 2021-01-22 01:00

    PYTHONPATH is used by the python interpreter. It is not the same as Windows' PATH environment variable. You can't use it as a search path for passing files to the interpreter on the command line.

    So, you need to specify a valid path to the file. Either by using he same command as you've been trying with the difference being your current directory is the same as the location of pacman.py, or by specifying the full path to the file.

    0 讨论(0)
提交回复
热议问题