XP Command Line:
helloworld.py is located in C:\python
C:\python is in the path xxx开发者_Python百科xxx is the user environment pathThis works:
xxxxx> cd C:\python
C:\python>helloworld.py
Hello World
This doesn't work:
xxxxx> helloworld.py
.....can't find the file ... but the folder with the file is in the PATH????
There's a difference between files with a specific a file extension (e.g. .py) being registered to be opened with a specific executable (e.g. python.exe
- Windows doesn't see any difference between this and a .pdf file opened by a PDF viewer, it's just opening it and doing something) and that file extension being registered as file extensions for executable files such that files with this extension be launches as an external command from a directory in PATH
(you can even omit the file extension in this case). The latter is specified in an enviromental variable called PATHEXT
- adding .PY
to the list should allow invoking the script directly from other locations.
try logging out and back in. technically you should only have to launch a new cmd.exe for it to work iirc, but if you can logout and back in your new environment variable should definitely be in affect.
Is python.exe in the directory c:\python?
type 'path' to check what the path is actually set to.
精彩评论