Configuration Methods for coexistence of multiple versions of Python

Source: Internet
Author: User

Configuration Methods for coexistence of multiple versions of Python

If the python 2 and python 3 environments are installed on the same PC at the same time, an error will occur when the python command is executed, and the operating system will find the default configuration for execution. How can we make python2 and python3 work together without affecting each other.

However, due to work requirements, we may need multiple python versions to coexist on our personal PC. What kind of settings should we make? This chapter will analyze and introduce this issue.

1. The configuration for coexistence of python2 and python3 enters the installation path of python2 as follows:


Install the file .png under python2.

Modify python.exeand rename it python2.exe.


Python2rename file .png

Go to the installation path of python3


Python 3 installation path File

The rename file python.exeis python3.exe, and pythondomainexeis pythonw3.exe.


Python3environmental name document .png

Configure the environment variables and configure the paths of python2 and python3 to the path environment variables.


Environment variable configuration .png

In this case, open the command line window of the system, enter the command python2 to enter the python2 development environment, and enter the name python3 to enter the python3 development environment.


Environment .png imported into python2and python3

2. commands executed when pip is used to install the module

Under normal circumstances, we also need to use the python pip command to install and configure a third-party module. If Pip is executed directly, an error occurs.

The general installation command syntax is as follows:

Copy codeThe Code is as follows: pip install Module name

However, we have installed two pythons on the PC and modified the name of the executable file python.exe. Therefore, an error occurs when executing pip directly.

2.1. Install a third-party module for python2

Open the command line tool and run the following command to install the modules required by python2.

Copy codeThe Code is as follows: python2-m pip install Module name

2.2. Install a third-party module for python3

Open the command line tool and run the following command to install the modules required by python3.

Copy codeThe Code is as follows: python3-m pip install Module name

2.3. View pip version


Execute the pipcommand .png in the specified python.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.