如何从命令行使用py而不是python访问python [英] how to access python from command line using py instead of python

查看:539
本文介绍了如何从命令行使用py而不是python访问python的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个非常奇怪的请求。一个可执行文件我有一个python脚本的系统调用像py file1.py
现在,在我的系统,虽然py显示为一个无法识别的内部或外部命令。 python file1.py工作但是。

I have a very weird request. An executable I have has a system call to a python script which goes like py file1.py Now, in my system though py is shown as an unrecognized internal or external command. python file1.py works however.

有一些方法,我可以得到我的Windows命令提示符来识别py和python指向同一个事情?

is there some way I can get my windows command prompt to recognize that py and python refer to the same thing?

推荐答案

py 命令带有Python3.x,多个Python解释器。例如,如果您安装了Python 3.4和2.7,则 py -2 将启动python2.7和 py -3 将启动python3.4。如果你只是使用 py 它将启动一个被定义为默认的。

py command comes with Python3.x and allow to choose among multiple Python interpreters. For example if you have both Python 3.4 and 2.7 installed, py -2 will start python2.7 and py -3 will start python3.4 . If you just use py it will start the one that was defined as default.

安装Python 3.x,声明Python 2.7为默认值, py 命令将执行它的工作。

So the official way would be to install Python 3.x, declare Python 2.7 as the default, and the py command will do its job.

但是如果你只想让 py 成为 python doskey py = python .exe 由@Nizil和@ergonaut提出将更简单...或者复制python.exe到py.exe27在Python27文件夹,如果你不想被困扰的限制 doskey

But if you just want py to be an alias of python, doskey py=python.exe as proposed by @Nizil and @ergonaut will be much simpler... Or copying python.exe to py.exe in Python27 folder if you do not want to be bothered by the limitations of doskey.

这篇关于如何从命令行使用py而不是python访问python的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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