Python2, 3 download and installation, environment configuration and Python2, 3 version coexistence configuration

1. Introduction to python version

Python includes two major versions, python2 and python3, among which python3 has improved some deficiencies of python2, but since many applications were developed with python2 in the past, python2 is still needed to maintain these applications, so python2 has not been completely eliminated.

At 23:06 on April 20, 2020, Beijing time, Python 2 maintainer and Release Manager Benjamin Peterson officially announced in the mail group that Python 2.7.18 was officially released, and this is the last version of Python 2.

2. Download Python

Python official website download address: Download Python | Python.org

Select the version to download according to the system

Note : The bitness of the operating system can be determined by the following operations: right click on this computer -> click properties -> view bitness

downloaded file

3. Installation process

Note: Install python2 or python3 according to the actual situation

1) Install python3

1. Double-click the downloaded python file [python-3.11.4-amd64.exe]

2. Check Add Python.exe to PATH, and then click Customize installation to go to the next step;

3. After entering Optional Features, click Next without any operation;

4. Click Browse to customize the installation path, or you can directly click Install to install, click install to install;

(Remember this path, it may be used later)

5. During the installation, wait for a while

6. Click Disable path length limit (modify the limit on the character length of the program in the computer);

7. Click Close to complete the installation.

2 ) Install python2

1. Double-click the downloaded python file [python-3.11.4-amd64.exe]

2. Check Install for all users, and then click Next to enter the next step;

3. Enter a custom path to customize the installation path, or you can directly click Next to enter the next step;

(Remember this path, it may be used later)

4. Select pip and Add python.exe to Path, so that environment variables can be added automatically.

5. During the installation, wait for a while

6. Click Finish to complete the installation.

3 ) Verify that the installation is successful

Note: Take python3 as an example for narrative display, and python2 is similar.

1. View recently added in win or search python directly

2. Press "Windows+R" -> input "cmd" -> click OK.

3. Enter "python" -> press Enter, if the information shown in the figure below appears, it indicates that the installation is successful (the command line changes to three greater than signs).

4. If the information shown in the figure below is displayed, you need to manually configure the environment variables (refer to the next section).

4. Environment variable configuration

(If the verification in the previous step is successful, you can skip this step)

Note: Take python3 as an example for narrative display, and python2 is similar.

When the command line searches for an executable file, it will search in the current directory. If it cannot find it, it will search in the directory specified by the Path variable. Therefore, adding the path of the executable file to Path can ensure that the program can be executed in any path.

1. Right click on This PC -> Click Properties

2. Click "Advanced System Settings"

3. Click "Environment Variables" (some computers may have to manually select the "Advanced" tab above)

4. Click to select "Path" -> click Edit

5. Open the installation path of python (set during installation, it may be different from the author) -> Click the address bar -> "Ctrl+C" to copy the path

6. On the "Edit Environment Variables" tab click New

7. Paste the path -> click OK

Five, Python2 , 3 version coexistence configuration

Based on the particularity of Python2 and 3, it is possible to install Python2 and 3 in one computer. Executing the "python" command on the command line will always enter python2 or 3, so how to enter python2 or python3 according to the user's wishes?

Open the python2 directory -> rename "python.exe" to a distinguishable name, such as: "python2.exe"

After the above operations, type "python2" on the command line to enter python2.

The same steps can be applied to python3 and different versions of the pip tool.

For simplicity, the author's computer only changed its name to python2 (python2), and python3 still enters through python.

Guess you like

Origin blog.csdn.net/xijinno1/article/details/131366220