At present, they are basically used python3 了 , But sometimes I will encounter older projects , Then the sad thing is that you need python2, It is easy to destroy the current python3 Environment , Actually python2 and python3 Yes, it can be installed at the same time , And it's easy to set up
Go first python Official website https://python.org/ download python2 and python3 Installation package
python3 Try to choose Windows installer (64-bit)
Installation procedure ,python2 You can choose msi Installation procedure
Install after downloading python3, Remember to check add to environment variable when installing , The installation process is not difficult , No screenshots. .
after , Start installation python2, Note that it is not added to the environment variable by default , We don't have to change it , We will add it manually later , So we need to remember the installation path
After they are all installed , open cmd or powershell, Input python, It should be possible to enter python3 Environment ,pip It's also python3 Of
We enter python2 Installation path for , And then directly put python.exe Renamed as python2.exe,
We open the environment variable , In turn, open Set up -- System -- About -- Advanced system setup -- environment variable
spot " newly build " You can create new environment variables , And put python2 The installation path of and Script Folders are added to the environment variable , For example, my path here is
C:\Python\Python27
C:\Python\Python27\Scripts
In turn, click “ determine ” Close these windows
restart cmd, Input python2
It should be possible to enter python2 The environment , Then you need to install pip2
python2 -m pip install --upgrade pip --force-reinstall
After it is installed, it can be used pip2
Command management python2 The module
Ubuntu20.04 Self contained python Of 3.X, If you want to python2, You can use commands
# install python2
sudo add-apt-repository universe
sudo apt update
sudo apt install python2
# install pip2
wget https://bootstrap.pypa.io/pip/2.7/get-pip.py
sudo python2 get-pip.py
pip2 -V