12

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.

4 Answers 4

17

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>
Sign up to request clarification or add additional context in comments.

2 Comments

That's the real deal!
how to get the path associated with each executable?
3

If you need to use multiple versions of Python, or run different sets of packages in the Python environment, you should probably just use Anaconda to create them, for example:

    conda create -n py36 python=3.6 anaconda

then you can just switch between them using

    activate <your-environment-name>

2 Comments

I'm not into anaconda but does conda create -n py36 python=3.6 anaconda create a virtual environment?
Yes, if you first install Anaconda, it will have a default python environment, but typically you'd want to set up a separate environment with whatever version of python plus a set of packages needed for your task that also match the version for that environment. The "-n py36" creates a new python environment called "py36", you can call it anything you like. The "python=3.6" is which version of the python interpreter to use. The "anaconda" and anything else is to select which packages to install in the newly created environment.
3

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

Comments

2

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

1 Comment

That what I did moving them up and down. I'm just trying to learn if there is a better way to do it.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.