开发者

XP with C:\python in path won't run files in C:\python

XP Command Line:

helloworld.py is located in C:\python

C:\python is in the path

xxx开发者_Python百科xxx is the user environment path

This 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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜