Software Testing | How to install multiple versions of Python on a Windows computer?

Insert image description here

Introduction

Installing multiple versions of Python is a very common task on Windows computers, especially when you need to use different versions of Python in different Python projects. Below is a detailed step-by-step guide to help you install multiple Python versions on Windows.

Step 1: Download the Python installer

  1. Visit Python official website, download Python installer, Python official website address:

https://www.python.org/downloads/windows/

  1. On the download page, we can see different versions of Python, usually there are two main versions of Python: Python 2.x and Python 3.x. Select the Python version to be installed, and click the download link of the corresponding version.

  2. On the download page, you can choose to download the stable release or the latest beta release. Normally, it is recommended to download the latest stable release.

Step 2: Run the Python installer

  1. After downloading the Python installer, double-click to run it. We will see an installation wizard similar to the following:

Insert image description here

  1. In the installation wizard, we need to check the following options:
  • Add Python xx to PATH: This option will allow you to easily access Python from the command line.
  • You can also select other customization options, make your selections according to your needs.
  1. Click the "Install Now" button to start installing Python. The installation process may take some time, wait for the installation to complete.

After the installation is complete, we will see a prompt that the installation was successful. Click the "Close" button.

Step 3: Install other Python versions

If we need to install multiple different versions of Python, repeat the above steps, select different Python versions and select different installation directories. Make sure each Python version is in a different folder to avoid conflicts between versions.

Step 4: Using a Python Virtual Environment

Using Python virtual environments can help us better manage different versions of Python and projects. Here are the basic steps for using a Python virtual environment:

  1. Open a command line terminal.

  2. Use the following command to install the virtualenv module if it is not already installed:

pip install virtualenv
  1. Create a new virtual environment. If we have multiple versions of Python installed, we can use the following command to create a myenvvirtual environment called:
virtualenv myenv
  1. Activate the virtual environment. Run the following command on the command line:
myenv\Scripts\activate

This will activate myenvthe virtual environment. We will see the name of the virtual environment in front of the command prompt, indicating that we are using that virtual environment.

  1. Within an activated virtual environment, we can use specific Python versions and libraries. Install required libraries and dependencies.

Step 5: Switch Python version

If we need to switch between different Python versions, we can use the following command:

py -<version> -m pip install <package>

where is the version number of the Python version we want to use, for example, 3.8 or 3.9. This will install the specified package in the specified Python version.

Guess you like

Origin blog.csdn.net/Tester_muller/article/details/132629087