How to access python from the command line using py instead of python

I have a very strange request. The executable that I have has a python script system call that looks like py file1.py Now, on my system, although py is shown as an unrecognized internal or external command. However, python file1.py works.

Is there any way to make my command line window recognize that py and python are related to the same thing?

0
python windows cmd
Sep 23 '15 at 14:18
source share
2 answers
Team

py comes with Python3.x and allows you to choose between 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 run the one that was defined as the default.

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.

But if you just want py be an alias of python , doskey py=python.exe suggested by @Nizil and @ergonaut will be much easier ... Or copy the python.exe file to the py.exe file in the Python27 folder if you don't want so that doskey restrictions doskey .

+8
Sep 23 '15 at 14:40
source share

At the command prompt, type:

 doskey py=python 

This would create a Windows alias, so using py would be the same as python.

+3
Sep 23 '15 at 14:32
source share



All Articles