Install python3.8 and python2.7

Install Python2 and Python3 on the same computer

At present, two versions of Python, Python2 and Python3, exist at the same time, and these two versions are being updated and maintained at the same time.

Whether to choose Python2 or Python3 depends on the version of the library and framework currently used.

For example: HTMLTestRunner, locustio support Python2, but do not support Python3.

So many times, Python2 and Python3 need to be installed on one computer at the same time.

 

This article mainly talks about how to install Python2 and Python3 on the same computer at the same time, and both can use pip normally.

 

1. Install Python2 (and pip)

1.1. Go to Python's official website https://www.python.org/ to download the Python installation file,

     For Windows users, if it is a 32-bit system, choose the x86 version; if it is a 64-bit system, choose the 64 version of the installation file.

     My own computer is 64-bit, the following example is explained in 64-bit.

     The name of the downloaded installation file looks like this: python-2.7.12.amd64.exe

 

1.2. Click the installation file "python-2.7.12.amd64" and keep clicking next. Special attention should be paid when selecting the installation path: There must be no spaces in the installation path of Python!

     To distinguish between Python2 and Python3, rename the python.exe file in this directory to python2.exe, as shown in the following screenshot:

     

 

1.3, add Python2 environment variables

     This computer--Properties--Advanced system settings--Advanced--Environmental variables--System variables--Path--Edit

     Add; E: \ setup \ Python27 \ Scripts \; E: \ setup \ Python27 \; here (write here according to your installation path, and pay attention to the English semicolon and other variable values ​​to separate;

                                                                                                   If you do not configure this variable, you will be prompted "not an internal command" when entering Python2 in cmd)

 

1.4. In the cmd, enter Python2. If the prompt in the figure below appears, it indicates that the installation of Python2 is successful

    

 

 1.5. Install setuptools.

     The pip to be installed in step 1.6 depends on setuptools, so you need to install setuptools before installing pip.

     Go to the official website https://pypi.python.org/pypi/setuptools to download, the name is similar to this "" setuptools-28.7.0.zip "" (download time is different, the version number may be different), unzip;

     Go to the unzipped directory in cmd (the directory where the setup.py file exists), execute> python2 setup.py install (Note: Since the python.exe file was renamed to python2.exe in the previous step 1.2, so here Be sure to write python2 when entering commands, not python)

 

1.6, install pip

       pip is a tool for installing and managing python packages. It is very easy to install python packages through pip.

       Go to the official website https://pypi.python.org/pypi/pip, download the compressed file of pip, the name after downloading is similar to this "" pip-8.1.2.tar "" (the download time is different, the version number may be Not the same), decompress;

       Enter the decompressed directory in cmd (the directory where the setup.py file exists), execute> python2 setup.py install (Note: The command executed here is pytho2, not python, the reason is the same as 1.5)

       At this time, let's take a look at the installation directory of Python2's pip E: \ setup \ Python27 \ Scripts, see the screenshot below, there are pip, pip2.7, pip2, indicating that the pip or pip2.7 or pip2 in cmd , The execution is the pip of Python2.

       

1.7. Enter pip2 or pip2.7 in cmd. If the following screenshot appears, it indicates that the pip installation was successful

        

 

 

Second, install Python3 (Since Python3 comes with pip, there is no need to install pip separately)

2.1. Go to Python's official website https://www.python.org/ to download the installation file of Python3,

     For Windows users, if it is a 32-bit system, choose the x86 version; if it is a 64-bit system, choose the 64 version of the installation file.

     My own computer is 64-bit, the following example is explained in 64-bit.

     The name of the downloaded installation file looks like this: python-3.5.0-amd64.exe

 

2.2. Click on the installation file "python-3.5.0-amd64.exe" and keep clicking next. Special attention should be paid when choosing the installation path: the installation path of Python cannot have spaces!

 

2.3. Check whether the environment variables of Python3 are added

       Python3 can choose to automatically add environment variables during installation, but sometimes it cannot be automatically added, so check it yourself at this time.

       This computer--Properties--Advanced system settings--Advanced--Environmental variables--System variables--Path

       If there are no environment variables related to Python3, add; E: \ setup \ Python35 \ Scripts \; E: \ setup \ Python35 \; (write according to your actual installation path here)

 

2.4. Check whether python3 is installed successfully, enter python in cmd, if the following picture shows, it is related to the version of python3, it means that the installation of python3 is successful.

        

 

        You may have a question: why not enter python3 here? Answer: Because the name of the python.exe file in the E: \ setup \ Python35 directory has not been changed to python3.exe. Changes have been made in Python2, so it doesn't matter if the changes are not modified here, as long as it can be the same as the python.exe file in the E: \ setup \ Python27 directory.

 

2.5, verify whether the pip in Python3 is automatically installed successfully

       Enter pip3 or pip3.5 in cmd (at this time, enter pip to see whether it is Python2 or pip in Python3). If there is a display in the screenshot, it indicates that pip in Python3 was automatically installed successfully.

       

 

       At this point you may have questions, how do you know whether to enter pip3 or pip3.5 instead of pip3.6? Because the name of the pip.exe file in the E: \ setup \ Python35 \ Scripts directory is determined: as shown below:

       

 

The above one and two will install python2 and python3 and their respective pip.

 

3. Specific use

If you use pip operation in Python2, use pip2 or pip2.7 related commands.

      Example: install selenium for Python2, enter pip2 install selenium or pip2.7 install selenium in cmd

 

If you are using pip operation in Python3, use pip3 or pip3.5 related commands.

      Example: Install selenium for Python3, enter pip3 install selenium or pip3.5 install selenium in cmd 

 

If some packages do not support the installation form of pip, download and decompress the corresponding file and put it into a certain directory, and use cmd to enter the decompressed directory

      If you want to install the package for Python2, execute python2 setup.py install

      If you want to install the package for Python3, execute python setup.py install  

Four, download module

During the download process, such a problem SyntaxError: invalid syntax, referring to this solution, was successfully resolved  

After this prompt appears, enter exit () directly to exit and install directly

 

 5. Use Tsinghua Mirror to download, the original link

 

Official address

First, if you only download a package temporarily, you
can use

1 pip install -i https://pypi.tuna.tsinghua.edu.cn/simple

If the image source is permanently modified

1 pip install pip -U
2 pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple

Use this if the network is not good

1 pip install -i https://pypi.tuna.tsinghua.edu.cn/simple pip -U
2 ``

 

 Pro speed test

Six, update pip

 

 Remind me to update, gave the command, so just enter the command it gives

python -m pip install --upgrade pip

At present, two versions of Python, Python2 and Python3, exist at the same time, and these two versions are being updated and maintained at the same time.

Whether to choose Python2 or Python3 depends on the version of the library and framework currently used.

For example: HTMLTestRunner, locustio support Python2, but do not support Python3.

So many times, Python2 and Python3 need to be installed on one computer at the same time.

 

This article mainly talks about how to install Python2 and Python3 on the same computer at the same time, and both can use pip normally.

 

1. Install Python2 (and pip)

1.1. Go to Python's official website https://www.python.org/ to download the Python installation file,

     For Windows users, if it is a 32-bit system, choose the x86 version; if it is a 64-bit system, choose the 64 version of the installation file.

     My own computer is 64-bit, the following example is explained in 64-bit.

     The name of the downloaded installation file looks like this: python-2.7.12.amd64.exe

 

1.2. Click the installation file "python-2.7.12.amd64" and keep clicking next. Special attention should be paid when selecting the installation path: There must be no spaces in the installation path of Python!

     To distinguish between Python2 and Python3, rename the python.exe file in this directory to python2.exe, as shown in the following screenshot:

     

 

1.3, add Python2 environment variables

     This computer--Properties--Advanced system settings--Advanced--Environmental variables--System variables--Path--Edit

     Add; E: \ setup \ Python27 \ Scripts \; E: \ setup \ Python27 \; here (write here according to your installation path, and pay attention to the English semicolon and other variable values ​​to separate;

                                                                                                   If you do not configure this variable, you will be prompted "not an internal command" when entering Python2 in cmd)

 

1.4. In the cmd, enter Python2. If the prompt in the figure below appears, it indicates that the installation of Python2 is successful

    

 

 1.5. Install setuptools.

     The pip to be installed in step 1.6 depends on setuptools, so you need to install setuptools before installing pip.

     Go to the official website https://pypi.python.org/pypi/setuptools to download, the name is similar to this "" setuptools-28.7.0.zip "" (download time is different, the version number may be different), unzip;

     Go to the unzipped directory in cmd (the directory where the setup.py file exists), execute> python2 setup.py install (Note: Since the python.exe file was renamed to python2.exe in the previous step 1.2, so here Be sure to write python2 when entering commands, not python)

 

1.6, install pip

       pip is a tool for installing and managing python packages. It is very easy to install python packages through pip.

       Go to the official website https://pypi.python.org/pypi/pip, download the compressed file of pip, the name after downloading is similar to this "" pip-8.1.2.tar "" (the download time is different, the version number may be Not the same), decompress;

       Enter the decompressed directory in cmd (the directory where the setup.py file exists), execute> python2 setup.py install (Note: The command executed here is pytho2, not python, the reason is the same as 1.5)

       At this time, let's take a look at the installation directory of Python2's pip E: \ setup \ Python27 \ Scripts, see the screenshot below, there are pip, pip2.7, pip2, indicating that the pip or pip2.7 or pip2 in cmd , The execution is the pip of Python2.

       

1.7. Enter pip2 or pip2.7 in cmd. If the following screenshot appears, it indicates that the pip installation was successful

        

 

 

Second, install Python3 (Since Python3 comes with pip, there is no need to install pip separately)

2.1. Go to Python's official website https://www.python.org/ to download the installation file of Python3,

     For Windows users, if it is a 32-bit system, choose the x86 version; if it is a 64-bit system, choose the 64 version of the installation file.

     My own computer is 64-bit, the following example is explained in 64-bit.

     The name of the downloaded installation file looks like this: python-3.5.0-amd64.exe

 

2.2. Click on the installation file "python-3.5.0-amd64.exe" and keep clicking next. Special attention should be paid when choosing the installation path: the installation path of Python cannot have spaces!

 

2.3. Check whether the environment variables of Python3 are added

       Python3 can choose to automatically add environment variables during installation, but sometimes it cannot be automatically added, so check it yourself at this time.

       This computer--Properties--Advanced system settings--Advanced--Environmental variables--System variables--Path

       If there are no environment variables related to Python3, add; E: \ setup \ Python35 \ Scripts \; E: \ setup \ Python35 \; (write according to your actual installation path here)

 

2.4. Check whether python3 is installed successfully, enter python in cmd, if the following picture shows, it is related to the version of python3, it means that the installation of python3 is successful.

        

 

        You may have a question: why not enter python3 here? Answer: Because the name of the python.exe file in the E: \ setup \ Python35 directory has not been changed to python3.exe. Changes have been made in Python2, so it doesn't matter if the changes are not modified here, as long as it can be the same as the python.exe file in the E: \ setup \ Python27 directory.

 

2.5, verify whether the pip in Python3 is automatically installed successfully

       Enter pip3 or pip3.5 in cmd (at this time, enter pip to see whether it is Python2 or pip in Python3). If there is a display in the screenshot, it indicates that pip in Python3 was automatically installed successfully.

       

 

       At this point you may have questions, how do you know whether to enter pip3 or pip3.5 instead of pip3.6? Because the name of the pip.exe file in the E: \ setup \ Python35 \ Scripts directory is determined: as shown below:

       

 

The above one and two will install python2 and python3 and their respective pip.

 

3. Specific use

If you use pip operation in Python2, use pip2 or pip2.7 related commands.

      Example: install selenium for Python2, enter pip2 install selenium or pip2.7 install selenium in cmd

 

If you are using pip operation in Python3, use pip3 or pip3.5 related commands.

      Example: Install selenium for Python3, enter pip3 install selenium or pip3.5 install selenium in cmd 

 

If some packages do not support the installation form of pip, download and decompress the corresponding file and put it into a certain directory, and use cmd to enter the decompressed directory

      If you want to install the package for Python2, execute python2 setup.py install

      If you want to install the package for Python3, execute python setup.py install  

Four, download module

During the download process, such a problem SyntaxError: invalid syntax, referring to this solution, was successfully resolved  

After this prompt appears, enter exit () directly to exit and install directly

 

 5. Use Tsinghua Mirror to download, the original link

 

Official address

First, if you only download a package temporarily, you
can use

1 pip install -i https://pypi.tuna.tsinghua.edu.cn/simple

If the image source is permanently modified

1 pip install pip -U
2 pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple

Use this if the network is not good

1 pip install -i https://pypi.tuna.tsinghua.edu.cn/simple pip -U
2 ``

 

 Pro speed test

Six, update pip

 

 Remind me to update, gave the command, so just enter the command it gives

python -m pip install --upgrade pip

Guess you like

Origin www.cnblogs.com/andrew-address/p/12689592.html