Developers often need to work with different versions of Python for various projects. Our project also had the same requirements. In this tutorial, I will show you how to install multiple versions of Python.
To install multiple versions of Python on Windows 11, first download the desired Python installers from the Python Downloads page. Run each installer, ensuring you check “Add Python to PATH” and customize installation settings to avoid conflicts. Verify installations using the Command Prompt with commands like py -3.8 --version and manage versions using the py launcher to switch between them easily.
Why Install Multiple Versions of Python?
There are several reasons why you might need multiple versions of Python on your system:
- Compatibility: Some projects may require a specific version of Python to run correctly.
- Testing: Developers often need to test their code against different Python versions to ensure compatibility.
- Learning and Experimentation: Experimenting with new features in the latest Python release while maintaining a stable environment for existing projects.
Install Multiple Versions of Python
Now, let me show you how to install multiple versions of Python on a Windows machine.
Step 1: Download Python Installers
First, download the installers for the Python versions you want to install. The official Python installers are on the Python Downloads page.
- Navigate to the Downloads page: Open your web browser and go to the Python Downloads page.
- Select the desired versions: Choose the versions you want to install (e.g., Python 3.8, Python 3.9, and Python 3.10).
- Download the installers: Click on the respective links to download the executable installers for each version.
Step 2: Install the First Version of Python
- Run the Installer: Locate the downloaded installer for the first version of Python (e.g.,
python-3.8.10-amd64.exe) and double-click to run it. - Customize Installation: On the first screen, check the box that says “Add Python to PATH” and then click on “Customize installation”.
- Select Optional Features: Ensure that the following options are checked:
- Documentation
- pip
- tcl/tk and IDLE
- Python test suite
- py launcher
- Advanced Options: In the Advanced Options screen, check the following:
- Install for all users
- Add Python to environment variables
- Precompile standard library
- Install: Click on “Install” to begin the installation. Once the installation is complete, close the installer.
Step 3: Install Additional Versions of Python
Repeat the installation process for each additional version of Python, customizing the installation settings as described in Step 2. To avoid conflicts, it’s crucial to ensure that “Add Python to PATH” is checked for each version.
Step 4: Verify Installations
After installing all desired versions of Python, you can verify the installations using the Command Prompt.
- Open Command Prompt: Press
Win + R, typecmd, and press Enter. - Check Python Versions: Type the following commands to check the installed versions:
python --version
python3 --version
py -3.8 --version
py -3.9 --version
py -3.10 --version
Each command should return the version number of the respective Python installation.
Step 5: Manage Multiple Versions with py Launcher
The py launcher allows you to switch between different Python versions easily. It is installed by default with Python on Windows.
- Specify Version: You can specify which version of Python to use by adding the version number after the
pycommand. For example:
py -3.8 script.py
py -3.9 script.py
py -3.10 script.py
- Set Default Version: To set a default Python version, you can create a
.pyfile association. Open Command Prompt and type:
py -3.9 --default
When you run without specifying a version, this sets Python 3.9 as the default version.
Step 6: Using Virtual Environments
Virtual environments are essential for managing dependencies and avoiding conflicts between different projects. They allow you to create isolated environments for each project, each with its own Python version and packages.
- Create a Virtual Environment: Open Command Prompt and navigate to your project directory. Then, run:
py -3.9 -m venv myenv
This command creates a virtual environment named myenv using Python 3.9.
- Activate the Virtual Environment: To activate the virtual environment, run:
myenv\Scripts\activate
- Deactivate the Virtual Environment: When you’re done working in the virtual environment, you can deactivate it by simply typing:
deactivate
Step 7: Install Packages in Virtual Environments
Once the virtual environment is activated, you can install packages using pip without affecting the global Python installation.
- Install a Package: For example, to install the
requestspackage, run:
pip install requests
- List Installed Packages: To list the installed packages in the virtual environment, run:
pip list
Step 8: Manage Multiple Virtual Environments
You can create multiple virtual environments for different projects, each using a different Python version. Simply repeat the steps in Step 6 for each project, specifying the desired Python version with the py command.
Step 9: Updating Python Versions
When a new version of Python is released, you can install it alongside your existing versions. Follow the same steps as described in Step 2 to download and install the new version. Then, update your virtual environments to use the new version if needed.
- Install the New Version: Download and install the new Python version from the Python Downloads page.
- Update Virtual Environment: To update an existing virtual environment to use the new Python version, recreate the environment with the new version:
py -3.11 -m venv myenv
Conclusion
In this tutorial, I have explained how to install multiple versions of Python in Windows OS.
You may also like:

I’m Michelle Gallagher, a Senior Python Developer at Lumenalta based in New York, United States. I have over nine years of experience in the field of Python development, machine learning, and artificial intelligence. My expertise lies in Python and its extensive ecosystem of libraries and frameworks. Throughout my career, I’ve had the pleasure of working on a variety of projects that have leveraged my skills in Python and machine learning. Read more…