在Windows上设置Python不要在cmd中键入python [英] Set up Python on Windows to not type python in cmd

查看:493
本文介绍了在Windows上设置Python不要在cmd中键入python的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何进行配置,使我不必键入 python script.py ,而只需要 script.py 在Windows上的CMD?

How do I have to configure so that I don't have to type python script.py but simply script.py in CMD on Windows?

我将我的python目录添加到包含python.exe但仍然脚本无法正常运行的%PATH%。

I added my python directory to %PATH% that contains python.exe but still scripts are not run correctly.

我试过django-admin.py运行 django-admin.py startproject mysite 给我
键入'django-admin.py help< subcommand>'以获取特定子命令的帮助。
使用python在其前面正确处理命令。

I tried it with django-admin.py Running django-admin.py startproject mysite gives me Type 'django-admin.py help <subcommand>' for help on a specific subcommand. Using python in front of it processes the command correctly.

这里有什么问题?

推荐答案

C:\> assoc .py=Python
C:\> ftype Python="C:\python27\python.exe %1 %*"

相关路径是 - 您还可以使用ftype设置命令行参数。

Or whatever the relevant path is - you can also set command line args using ftype.

以给出后缀( .py ),类似于它对 .exe 文件的工作原理,添加 .py 添加到(全局) PATHEXT 变量的分号分隔列表中。

In order to make a command recognized without having to give the suffix (.py), similar to how it works for .exe files, add .py to the semi-colon separated list of the (global) PATHEXT variable.

这篇关于在Windows上设置Python不要在cmd中键入python的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆