How to make python scripts executable on Windows? [duplicate]

橙三吉。 提交于 2019-12-17 02:31:42

问题


Possible Duplicate:
Set up Python on Windows to not type python in cmd

When I use python on Linux, or even Mac OS from command line, I take advantage of the shebang and run some of my scripts directly, like so: ./myScript.py. I do need to give this script executable permissions, but that is all.

Now, I just installed Python 3.1.2 on Windows 7, and I want to be able to do the same from command line. What additional steps do I need to follow?


回答1:


This sums it up better than I can say it:

http://docs.python.org/faq/windows.html

More specifically, check out the 2nd section titled "How do I make Python scripts executable?"

On Windows, the standard Python installer already associates the .py extension with a file type (Python.File) and gives that file type an open command that runs the interpreter (D:\Program Files\Python\python.exe "%1" %*). This is enough to make scripts executable from the command prompt as foo.py. If you’d rather be able to execute the script by simple typing foo with no extension you need to add .py to the PATHEXT environment variable.



来源:https://stackoverflow.com/questions/4235834/how-to-make-python-scripts-executable-on-windows

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!