Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to switch between python version Windows

Tags:

python

windows

Im trying to switch between python versions 3.6.6 and 3.7.0 in windows. I tried py -3.6.6 and doesn't work. Looked for options in py -h, found none. I saw a couple of answers for switching between python versions 2.x and 3.x by adding #!python3 at the start of the file.

I'm able to switch between these by moving path variables up and down but I want to know if there is a option to switch between versions in cmd like there is brew switch python version in IOS.

Thank you.

like image 226
Tarun Kolla Avatar asked Sep 02 '18 02:09

Tarun Kolla


3 Answers

If You have python of the same version with different subversion e.g. 2.6, 3.7,.. 3.9.
Use the below command to open specific python version's terminal in command prompt:

py -2.6
py -3.7
.

for installing modules in command prompt:

py -2.6 -m pip install <modules>
py -3.7 -m pip install <modules>
like image 175
NevetsKuro Avatar answered Nov 18 '22 06:11

NevetsKuro


Change the path in environment variable after downloading python 3.7.0 in windows where you can find in the properties of My Computer in Advanced System Settings

like image 20
Akash Badam Avatar answered Nov 18 '22 06:11

Akash Badam


The easiest way is simply type py -2 if you want to use python2, and py -3 if you want to use python3.

like image 3
Zhe Huang Avatar answered Nov 18 '22 06:11

Zhe Huang