cannot run python script file using windows prompt
Question: 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 such file or directory"_

when I try the command:

    
    
    c:\Program Files (x86)\Python27>python pacman.py
    

This particular python script file _pacman.py_ is located in the following
folder:

C:\Users\Chris\Dropbox\edX\CS188x\search

So I added this folder to PYTHONPATH and confirmed that is was there using the
following code:

    
    
    >>> import sys
    >>> sys.path
    ['', 'C:\\Program Files (x86)\\Python27\\Lib\\idlelib', 'C:\\Users\\Chris\\Dropbox\\edX\\CS188x\\search', 'C:\\windows\\syste...
    

I also checked the permissions on this file:

    
    
    >>> os.access("C:\Users\Chris\Dropbox\edX\CS188x\search\pacman.py",os.W_OK)
    True
    >>> os.access("C:\Users\Chris\Dropbox\edX\CS188x\search\pacman.py",os.R_OK)
    True
    >>> os.access("C:\Users\Chris\Dropbox\edX\CS188x\search\pacman.py",os.X_OK)
    True
    

So I am really not sure why I can't run this file, even though its path has
been added to PYTHONPATH. Any help would be greatly appreciated. Thank you.


Answer: 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.

