Hi @EMP_H ,

Yes, you should be able to switch between python versions. As a standard, it is recommended to use the python3 command or python3.7 to select a specific version. The py.exe launcher will automatically select the most recent version of Python you've installed. You can also use commands like py -3.7 to select a particular version, or py --list to see which versions can be used. HOWEVER, the py.exe launcher will only work if you are using a version of Python installed from python.org. When you install Python from the Microsoft Store, the py command is not included. Since you're using the Microsoft Store version of Python, you should use the python3 (or python3.7) command.

Hope that helped. Please let us know if you have further questions.

Best,
Grace

For information please read this FAQ doc for using python on windows.

Answer from Grmacjon-MSFT on learn.microsoft.com
Top answer
1 of 7
31

Use Virtualenv.

There is more information here: Working with virtualenv.

Using virtualenv you can create a new virtual python environment with whatever version of Python you want for each project or application. You can then activate the appropriate environment when you need it.

To expand on my answer:

You can install multiple versions of Python on your computer (I have 2.4, 2.5, 2.6 and 3.1 on my machine - I install each from source). I use a Mac, and keep my system Python as whatever OS X sets as the default.

I use easy_install to install packages. On ubuntu you can get easy_install like this:

sudo apt-get install python-setuptools

To install virtualenv then do:

easy_install virtualenv

I tend to create a new virtualenv for each project I'm working on and don't give it access to the global site-packages. This keeps all the packages tight together and allows me to have the specific versions of everything I need.

virtualenv -p python2.6 --no-site-packages ~/env/NEW_DJANGO_PROJECT

And then whenever I am doing anything related to this project I activate it:

source ~/env/NEW_DJANGO_PROJECT/bin/activate

If I run python now it uses this new python. If I use easy_install it installs things into my new virtual environment.

So, virtualenv should be able to solve all of your problems.

2 of 7
6

Pythonbrew is a magical tool. Which can also be called as Python version manager similar to that of RVM-Ruby version manager but Pythonbrew is inspired by Perlbrew.

Pythonbrew is a program to automate the building and installation of Python in the users $HOME.

 Dependencies – curl

Before Installing the Pythonbrew, Install “curl” in the machine, to install curl use the below command in the terminal, give the the password for the user when prompted.

 $sudo apt-get install curl

After Installing the curl, Now Install Pythonbrew, copy and paste the following commands in the terminal and type the password for the user when prompted.

Recomended method of installation - Easy Install

 $ sudo easy_install pythonbrew 

To complete the installation, type the following command

 $pythonbrew_install

Alternate method of installation:

Use curl command to download the latest version of pythonbrew from github.

curl -kLO http://github.com/utahta/pythonbrew/raw/master/pythonbrew-install

After downloading, change “pythonbrew-install” to “executable”

 chmod +x pythonbrew-install

Then, run the pythonbrew-install in the terminal

./pythonbrew-install

Now the Pythonbrew has been installed in the “Home Directory” i.e., /home/user/.pythonbrew

Next, copy and paste the following line to the end of ~/.bashrc

*NOTE: change “user” to your user name in the system

source /home/user/.pythonbrew/etc/bashrc

Thats it! Close the terminal. Steps to Install different versions of Python:

Open a new terminal, type the following command or copy and paste it.

$pythonbrew install 2.6.6

This will install Python 2.6.6 and to install Python 2.7 or Python 3.2, change the version number in the previous command.

$pythonbrew install 2.7

or

$pythonbrew install 3.2

Update: If you get error while Installing then Install using the below command.

$pythonbrew install --force 2.7

or

$pythonbrew install --force 3.2

How to manage different versions of Python installed in system

For instance, if Python 2.6.6, Python 2.7 and Python 3.2 is installed in your system, switching between the versions can be done as follows:

By default, Python 2.6.6 will be active and in order to switch to Python 2.7 use the below command

$pythonbrew switch 2.7

The default Python is changed to Python 2.7.

Now, to switch to Python 3.2 change the version number in the previous command.

$pythonbrew switch 3.2

Use the below command to check or list the installed Python versions

$pythonbrew list

Use the below command to check or list the available Python Versions to install

$pythonbrew list -k

To uninstall any of the installed Python version (for example to uninstall Python 2.7), use the below command.

$pythonbrew uninstall 2.7

Use the below command to update the Pythonbrew

$pythonbrew update

Use the below command to disable the Pythonbrew and to activate the default version

$pythonbrew off

Enjoy the experience of installing multiple versions of Python in single Linux / ubuntu machine!

Discussions

How can I switch default python version on command line?
I use "pyenv" for this. It is a package you install that lets you download different python versions and easily switch between them. More on reddit.com
🌐 r/learnpython
2
3
July 22, 2024
How to downgrade python from 3.7 to 3.6 - Stack Overflow
I'm trying to install tensorflow but it needs a Python 3.6 installation and I only have Python 3.7 installed. I tried to switch using brew and pyenv but it doesn't work. Does anyone know of a way... More on stackoverflow.com
🌐 stackoverflow.com
How to install an older version of python - Stack Overflow
How can I install python 3.4 (Windows version) when a newer version (3.5.1) is now available. My app specifically is looking for 3.4. I can't seem to find a download for any of the older versions. More on stackoverflow.com
🌐 stackoverflow.com
What is the best way to upgrade an old version of python
I have 2.7 version of Python installed on my computer and many projects built on that version. What would be the best way to upgrade cleanly and get rid those old projects. More on forum.freecodecamp.org
🌐 forum.freecodecamp.org
0
0
January 17, 2021
Top answer
1 of 12
71

The simplest way would be to add an alias to python3 to always point to the native python installed. Add this line to the .bash_profile file in your $HOME directory at the last,

alias python="python3"

Doing so makes the changes to be reflected on every interactive shell opened.

2 of 12
27

pyenv is a 3rd party version manager which is super commonly used (18k stars, 1.6k forks) and exactly what I looked for when I came to this question.

edit: I use it for several years now. Works like a charm.

Installation

Install pyenv.

Usage

$ pyenv install --list
Available versions:
  2.1.3
  [...]
  3.8.1
  3.9-dev
  activepython-2.7.14
  activepython-3.5.4
  activepython-3.6.0
  anaconda-1.4.0
  [... a lot more; including anaconda, miniconda, activepython, ironpython, pypy, stackless, ....]

$ pyenv install 3.8.1
Downloading Python-3.8.1.tar.xz...
-> https://www.python.org/ftp/python/3.8.1/Python-3.8.1.tar.xz
Installing Python-3.8.1...
Installed Python-3.8.1 to /home/moose/.pyenv/versions/3.8.1

$ pyenv versions
* system (set by /home/moose/.pyenv/version)
  2.7.16
  3.5.7
  3.6.9
  3.7.4
  3.8-dev

$ python --version
Python 2.7.17
$ pip --version
pip 19.3.1 from /home/moose/.local/lib/python3.6/site-packages/pip (python 3.6)

# Writing the .python-version file does the switch:
$ mkdir pyenv-experiment && echo "3.8.1" > "pyenv-experiment/.python-version"
# alternatively, you could use `pyenv local 3.8.1`
$ cd pyenv-experiment

$ python --version
Python 3.8.1
$ pip --version
pip 19.2.3 from /home/moose/.pyenv/versions/3.8.1/lib/python3.8/site-packages/pip (python 3.8)
Top answer
1 of 15
93

Here is a canonical summary which sums up different solutions for the variety of operating system Python runs on. What follows are possibilities for Microsoft Windows, Linux, macOS and Misc.

As mentioned those are just possibilities - by no means do I claim to have a complete list whatsoever.


Microsoft Windows

Option 1

In general, it's suggested to use virtual environments (I highly suggest looking at the official Python documentation). With this approach, you easily can set up project-specific Python versions (as well as libraries). Easily manageable and the best part: There are lots of tutorials on the internet on how to approach this:

  • Using VirtualEnv with multiple Python versions on windows
  • https://www.freecodecamp.org/news/installing-multiple-python-versions-on-windows-using-virtualenv/
  • etc.

1.) Open command prompt ("cmd") and enter pip install virtualenv.

2.) Install your desired Python version via https://www.python.org/downloads ; Remember: Do not add to PATH!

3.) Type into the command prompt: virtualenv \path\to\env -p \path\to\python_install.exe, whereas \path\to\env shall be the path where your virtual environment is going to be and \path\to\python_install.exe the one where your freshly (presumably) installed Python version resides.

4.) Done! You now have a virtual environment set up! Now, to activate the virtual environment execute the batch file which is located inside the \path\to\env\Scripts\activate.bat. (cf. this website or an official Python guide)

Option 2

The basic option would be to uninstall the unwanted Python version and re-install the favored one from https://www.python.org/downloads/. To remove the "old" version go to Control Panel -> "Uninstall a program" -> Search for "Python" -> Right-click on the Python name -> Uninstall. Bear in mind that Python usually has a PATH variable stored, hence you should remove it as well - Check the following links for this:

  • https://support.foundry.com/hc/en-us/articles/209642805-Q100127-How-to-delete-unset-environment-variables
  • Remove unwanted path name from %path% variable via batch

Now double-check whether there are any remaining files where Python used to be stored. Usually, you can find all the Python files at either C:\Program Files (x86)\Pythonxx, C:\Users\username\AppData\Local\Programs\Pythonxx or C:\Pythonxx or all of them. You might have installed it in another directory - check where it once was.

Now after de-installing just re-install the wanted version by going to the download page and follow the usual installation process. I won't go into details on how to install Python.. Lastly, you might check which version is currently installed by opening the command prompt and typing python -V.

Option 3

This approach is pretty similar to the second one - you basically uninstall the old one and replace it by your favored version. The only thing that changes it the part regarding how to uninstall the unwanted Python distribution: Simply execute the Python3 installer you originally used to install Python (it's usually stored in your Python directory as mentioned above; for more assistance check out this). There you get an option to repair or uninstall, proceed by choosing uninstall, and follow the steps provided via the uninstaller.

No matter how you uninstall Python (there are many resources on this topic, for example this Stack Overflow question or a problem thread a user by the name of Vincent Tang posted on the Stack Exchange site Super User, etc.), just reinstall the wanted Python version by following the steps mentioned in Option 2.

Option 4

Option 4 deals with Anaconda. Please refer to this site on how to install Anaconda on Windows. Step 9 is important as you don't want to install it as your default Python - you want to run multiple versions of Python:

Choose whether to register Anaconda as your default Python. Unless you plan on installing and running multiple versions of Anaconda or multiple versions of Python, accept the default and leave this box checked.

Follow the official tutorial I linked above.

Once done you can create the following commands individually in the anaconda prompt: To overwrite the default python version system-wise use conda install python=3.6 or to create a virtual environment go ahead and use conda create -n $PYTHON36_ENV_NAME python=3.6 anaconda whereas $PYTHON36_ENV_NAME is the custom name you can set. Credit where credit is due - the user @CermakM from this thread strongly influenced this snippet.

In my research I encountered a bunch of useful Stack Overflow threads - you might check them out if you go the tough road with Anaconda:

  • How to downgrade the Python Version from 3.8 to 3.7 on windows?
  • downgrade python version from 3.8 to lower one in a given conda environment

Option 5

What follows isn't a downgrade in the classical sense - though for the sake of completeness I decided to mention this approach as well. On Windows you're also able to run multiple Python versions - an infamous thread on StackOverflow deals with this question, thus I politely refer you to there for further reading purposes.


Linux

Option 1

Pretty analog to the third option for Windows I highly suggest you use a virtual environment such as Anaconda. Anaconda - or short conda - is also available on Linux. Check the official installation documentation here. Once again this thread is highly suggested on how to overwrite a Python version, respectively how to specifically create an environment with your wanted Python version.

Option 2

Another highly suggested virtual environment is Pyenv. The user @Sawan Vaidya described in this Stack Overflow question on how to up-or downgrade a Python version with the help of Pyenv. You can either set a Python version globally or create a local environment - both explained in the mentioned thread.

Option 3

Another user, namely @Jeereddy, has suggested to use the software package management system Homebrew. He explained this option thoroughly in this current question:

$ brew unlink python
$ brew install --ignore-dependencies https://raw.githubusercontent.com/Homebrew/homebrew-core/e128fa1bce3377de32cbf11bd8e46f7334dfd7a6/Formula/python.rb
$ brew switch python 3.6.5

Option 5

No need to reinvent the wheel - this thread is filled with lots of beautiful running approaches such as the one by @Sidharth Taneja.

  1. Download your wanted Python version from https://www.python.org/downloads/release and install it as a normal package.
  2. Run cd /Library/Frameworks/Python.framework/Version
  3. Execute ls to list all installed Python versions
  4. Run sudo rm -rf 3.7, removing Python version 3.7 - can be repeated for whatever version(s) you want to delete
  5. Check python3 -v, it should display the version you originally wanted to have installed

Option 6

What a goldmine this thread is! As @nondetermistic has described in-depth (direct link to his post):

Install Python source code as it is like this:

#Taken Python 3.6 as an example
$ mkdir /home/<user>/python3.6
$ ./configure --prefix=/home/<user>/python3.6/
$ make altinstall

You're now able to either add the downloaded version (/home/<user>/python3.6/bin) to PATH as well as lib to LD_LIBRARY_PATH or just create a virtual environment by: /home/<user>/python3.6/bin/python3.6 -m venv env-python3.6. A very aesthetic and simple solution to run multiple Python versions on your system.


macOS

Option 1

Using pyenv with Homebrew - credit to @Shayan with his reply here:

1.) Installing pyenv with Homebrew:

brew update
brew install pyenv

2.) Cloning the GitHub repository to get latest pyenv version:

 git clone https://github.com/pyenv/pyenv.git ~/.pyenv

3.) Defining the environment variables as follows

echo 'export PYENV_ROOT="$HOME/.pyenv"' >> ~/.bash_profile
echo 'export PATH="$PYENV_ROOT/bin:$PATH"' >> ~/.bash_profile

4.) Restarting shell so PATH change works

exec "$SHELL"

5.) Checking the available Python versions

pyenv install --list

6.) Installing the wanted Python version, e.g. 3.6

pyenv install 3.6

7.) Setting it globally (you can also go ahead and only use it in a certain environment)

pyenv global 3.6

8.) Check the Python version the system is using - your wanted / downgraded version should be displayed here.

python3 --version

Option 2

Similar to previous approaches you can download Anaconda on macOS as well. For an installation guide click here. The usage is pretty much the same as I've already described in Option 4 of the Windows guide. Please check out above.

Other options

In this case it's getting pretty repetitive. I kindly suggest you to check the following resources for further reading:

  • https://prodevsblog.com/questions/125949/macos-how-to-downgrade-homebrew-python/
  • https://www.xspdf.com/resolution/51291818.html
  • How to downgrade python version from 3.8 to 3.7 (mac)
  • https://weknowinc.com/blog/running-multiple-python-versions-mac-osx

Misc

When writing this post I had the problem of not knowing where to draw the line. When looking up the operating systems Python currently supports you get a huge list, including the ones I mentioned, i.e. Linux, Microsoft Windows and macOS, though obviously different Linux distributions are single-handedly treated, e.g. CentOS, Arch Linux or Fedora should deserve a spot as well - or shall I make separate options for Windows 10, 7, etc.?

Due to the high degree of repetitiveness as far as modules like Homebrew, Conda or alike are concerned I decided to limit my list to the "main three" operating systems - distributions like Ubuntu (How do I downgrade my version of python from 3.7.5 to 3.6.5 on ubuntu), CentOS (How to downgrade python version on CentOS?) can be easily researched on Stack Overflow. Most often than not you can apply solutions from the Linux tab for said distributions. The same goes with Windows and macOS (versions).

2 of 15
43

If you are working with Anaconda, then

conda install python=3.5.0
# or maybe 
conda install python=2.7.8
# or whatever you want....

might work.

Find elsewhere
🌐
freeCodeCamp
forum.freecodecamp.org › python
What is the best way to upgrade an old version of python - Python - The freeCodeCamp Forum
January 17, 2021 - I have 2.7 version of Python installed on my computer and many projects built on that version. What would be the best way to upgrade cleanly and get rid those old projects.
🌐
Tutor Python
tutorpython.com › downgrade-python-version
3 Ways to Downgrade Python Version - Tutor Python
December 25, 2024 - If you prefer not to use tools like pyenv or virtual environments, you can manually uninstall the current Python version and install an older one. To uninstall Python 3.11 on Windows, open the Control Panel and navigate to “Add or Remove Programs.” · Locate Python 3.11, right-click on ...
🌐
Medium
medium.com › swlh › how-to-run-a-different-version-of-python-from-your-terminal-fe744276ff22
How to Run Different Versions of Python From Your Terminal.
September 7, 2020 - Run older version of Python at the same time as the default version. Useful for Kivy and other libraries that work with specific versions of Python.
🌐
AskPython
askpython.com › home › downgrade from python 3.7 to 3.6 on windows, macos, and linux
Downgrade From Python 3.7 to 3.6 on Windows, MacOS, and Linux - AskPython
April 10, 2025 - There are a couple of good options for downgrading Python on Windows: The simplest method is to install an older Python version separately alongside the existing installation. Download the Python 3.6 installer for Windows from python.org.
🌐
Reddit
reddit.com › r/learnpython › how to download and use older versions of python?
r/learnpython on Reddit: how to download and use older versions of python?
October 9, 2023 - You can download older versions of Python. ... Another option - at least for linux or macOS - is Homebrew, which provides bottled (= precompiled) versions for the maintained releases of Python 3.y on the most used architectures - and falls back ...
🌐
Reddit
reddit.com › r/learnpython › [deleted by user]
need to install older python versions - how? : r/learnpython
February 10, 2025 - Go to the Python releases page and navigate to the specific version you need (e.g., 3.10 or 3.8). ... A manager is 100% the way to go. And if you're going to stay in Python, learning uv is worth the time. ... I seriously cannot thank you enough! I decided to use uv, but I need a bunch of other ...
🌐
GeeksforGeeks
geeksforgeeks.org › how-to-download-python-old-version-and-install
How to Download Python Old Version and Install - GeeksforGeeks
July 31, 2023 - Step 1: First, we have to go to the official website of Python "https://www.python.org/downloads/" and when we scroll down the page we get the old release version of Python as seen in the screenshot below.
🌐
Jerry Ng
jerrynsh.com › how-to-manage-and-update-python-version
How to Update Python Version: The Better Way - Jerry Ng
December 9, 2024 - Now, you can easily switch between different Python versions: # Go to my project cd ~/github.com/ngshiheng/burplist # Project current Python version python --version # Python 3.12.1 # But, I need Python 3.8.13 asdf local python 3.8.13 # Yay! python --version # Python 3.8.13 · That’s it! You'll likely find yourself using this set of commands about 80% of the time.
🌐
Medium
medium.com › @codelancingg › how-to-downgrade-python-version-fb7b9087e776
How to Downgrade Python Version. DOWNGRADING PYTHON VERSION: A SIMPLE… | by Codelancing | Medium
February 15, 2024 - Are you facing compatibility issues or simply need to switch back to an older Python version? Downgrading Python is a straightforward process that can be done effortlessly. In this blog post, we’ll guide you through the steps to downgrade your Python version with easy-to-follow examples. ... Checking your current Python version is the first crucial step before proceeding with any downgrade. This step ensures that you are aware of ...
🌐
Python.org
discuss.python.org › python help
Python 3.x script to earlier versions of Python - Python Help - Discussions on Python.org
March 29, 2023 - As title, is there a way to convert a script made with python 3.x to an earlier version of Python for backward compatibility with older systems (i.e., Windows 7)? Some kind of compiler made just for this? Thanks in adva…
🌐
Hrekov
hrekov.com › blog › switch-python-version
Switching Python Versions: Comprehensive Guide | Backend APIs, Web Apps, Bots & Automation | Hrekov
November 18, 2025 - It manages its own Python versions completely separate from the system or Pyenv. Create New Environment: conda create -n my_env python=3.10 ... Switch Version: Use conda install python=3.12 to change the version within the active environment.