Home > Article > Backend Development > Configuration method for coexistence of multiple versions of Python
This article shares with you the development environment of python2 and python3 required to be installed on the PC due to work requirements. So how should we operate? Let’s discuss it below.
In the same PC, if Python2 and Python3 environments are installed at the same time, an error will occur when executing the python command, 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 needs, we may need multiple python versions to coexist on our personal PCs. What kind of settings should be made? This chapter will analyze and introduce the use of this issue
1. To configure the coexistence of python2 and python3 versions, enter the installation path of python2 as follows
The file in the Python2 installation path.png
Modify python.exe and rename it to python2.exe
File under the python3 installation path
python3 environment rename file.png
Environment variable configuration.png
Enter the environment of python2 and python3.png
Copy code The code is as follows:
pip install module nameHowever, we installed two versions of python on the PC and modified the name of the executable file python.exe, so an error will occur when directly executing pip. 2.1. Install third-party modules for python2Open the command line tool and execute the following command to install the modules required for python2
Copy code The code is as follows:
python2 -m pip install module name2.2. Install third-party modules for python3Open the command line tool and execute Use the following command to install the modules required for python3Copy code The code is as follows:
python3 -m pip install module name2.3. Check the pip versionExecute the pip command in the specified version of python.png
The above is the detailed content of Configuration method for coexistence of multiple versions of Python. For more information, please follow other related articles on the PHP Chinese website!