[英].py files opens up in a text editor when run from cmd
Whenever I try to run a .py file from cmd it opens up in a text editor(np++).每当我尝试从 cmd 运行 .py 文件时,它都会在文本编辑器(np++)中打开。 I'm trying to run the following:
我正在尝试运行以下命令:
django-admin.py startproject testprj
Even if I run 'setup.py install'即使我运行“setup.py install”
You need to change the file association so that .py files open with Python executable, typically located in C:\\Python<version>\\
and not Notepad++您需要更改文件关联,以便使用 Python 可执行文件打开 .py 文件,通常位于
C:\\Python<version>\\
而不是 Notepad++
Changing this should be easy, but here is how to do it.改变它应该很容易,但这里是如何做到的。
Also, read here on to set the environment path so that the Python executable is found without you having to navigate to C:\\Python2.6.此外,请继续阅读此处设置环境路径,以便无需导航到 C:\\Python2.6 即可找到 Python 可执行文件。
Your Windows file associations are set to open .py
files in a text editor.您的 Windows 文件关联设置为在文本编辑器中打开
.py
文件。 You have to change those to use the python.exe
interpreter, or you can prefix all your commands with python, like this:您必须更改这些以使用
python.exe
解释器,或者您可以使用 python 为所有命令添加前缀,如下所示:
python django-admin.py startproject testprj
If you want to change your file associations, and you are running Vista or Windows 7, you can change them in 'Control Panel'->'Default Programs'->'Associate a file type or protocol with a program'如果要更改文件关联,并且运行的是 Vista 或 Windows 7,则可以在“控制面板”->“默认程序”->“将文件类型或协议与程序关联”中更改它们
It is very easy: `python (or directory to python.exe with python.exe on the end) filename (Or a again directory to the file with the name and extension on the end.) any arguments. 这很容易:`python(或python.exe的目录,最后是python.exe)文件名(或者是文件的另一个目录,最后是名称和扩展名。)任何参数。
So if i would want to run setup.py on my desktop: I could eather: 所以,如果我想在我的桌面上运行setup.py:我可以:
use cd to get all the way to the folder where the .py file is 使用cd来获取.py文件所在的文件夹
and then 然后
"pathtopythonwithoutnameonend\python.exe" (In "!) setup.py
or 要么
python "pathtofolderinwhichsetup.pyiswithoutname\setup.py" (In "!)
It is that easy. 就这么简单。 Seriously.
认真。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.