Call different version of Python on the Windows terminal?

1

I wish I could call any version of Python that I installed on the Windows terminal (I have 2.7, 3.6 and 3.7). I would like to call you with python , python36 and python37 or in any other way if you have more relevant ideas. However, when I tried to do it for Python 3.7, it did not seem to work.

C:\>set PATH=C:\Program Files\Python 3.7;%PATH%

C:\>set PYTHONPATH=%PYTHONPATH%;C:\My_python_lib

C:\>python
Python 2.7.15 (v2.7.15:ca079a3ea3, Apr 30 2018, 16:30:26) [MSC v.1500 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>>

Here are my environment variables:

    
asked by ThePassenger 14.12.2018 в 11:51
source

1 answer

3

On Windows, the launcher py.exe is usually installed. You can detect the versions you have installed and allow you to choose which one to use.

To see if you have it correctly configured test (in a terminal):

> py --list
Installed Pythons found by py Launcher for Windows
 -3.7-32 *
 -3.6-64

(This is what I get)

When you put py without parameters, it launches the most recent version, but if you want another you can specify it after a script. For example:

> py
Python 3.7.1 (v3.7.1:260ec2c36a, Oct 20 2018, 14:05:16) [MSC v.1915 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> quit()

> py -3.6
Python 3.6.0 |Continuum Analytics, Inc.| (default, Dec 23 2016, 11:57:41) [MSC v.1900 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> quit

You can also use it to launch scripts, of course:

> py -3.6 holamundo.py
Hola!
    
answered by 14.12.2018 / 12:06
source