This is the 18th day of my participation in the August Challenge

Windows installs python2 on top of the existing python3

As two major versions of the same programming language,Python2 and Python3 have many differences and compatibility issues. Python3 has now become mainstream and is officially recommended to use Python3 since it has been released for many years. But there are still a few people who stick with Python2, and there are some people who continue to use Python2 because they need Python2 to run their code that was written in Python2, and it’s almost always Python2.7.

Python3 had been installed until it was discovered that many projects were using Python2 and the two were incompatible, so Python2 was installed again.

To record their own notes, and share with you, there are many excellent articles, if you like to click on the attention oh ~

1. Download python2.7.15

Download the corresponding version from the Python official website

www.python.org/downloads/r…

2. Install python2

References: blog.csdn.net/weixin_4379…

Note the location of the installation and the setting of the environment variables

3. Replace the interpreter

Select Add and the screenshot shows the effect after the addition

Note the specific location chosen for the interpreter python27.exe, such as this

PIP used when Python2 and Python3 are installed

Reference: blog.csdn.net/kuronekonan…

On my computer, I try to distinguish Python2 from 3 because I installed 3 first and then 2. By default, the program name for 3 is Python, and I changed the program name for 2 to Python27. So when I call the PIP package, it should correspond to,

When I need to use python3, I use the PIP install library name as before. All piPs by default operate on PYTHon3

To distinguish between using python2 specifically, use the following method:

Method 1:

Python3 python -m PIP install library name Python2 Python27 -m PIP install library name

Method 2:

py -2 -m pip install XXXX//Python2Or py -3 -m pip install XXXX//Python3
Copy the code

If python27 is successfully installed, you can reinstall the package:

Some other PIP uses directives, such as looking at the default Python3 package installed using PIP

pip list1
Copy the code

Python2 View the PIP installation package name and version

python27 -m pip list 
Copy the code

Python3 View the PIP installation package and version

python3 -m pip list
Copy the code

Ok, update PIP

python27  -m pip install --upgrade pip
Copy the code

In general, direct PIP use is python3 by default, and python27 is used by prefixing “python27-m” to each PIP instruction

5. Python27 runs the program and outputs garbled characters

The questions are as follows:

Just set it:

The results are as follows:

Found or error, but not in garbled code, but unable to identify Chinese

References: blog.csdn.net/qq_42168575…

Python2 does not support Chinese. The solution is as follows:

Reset:

The solution is as follows (choose one of two)

1) (novice) add #coding= UTF-8 to the first line of the file

2) (official recommendation) Add: — coding: UTF-8 — at the top of the file

Now that you’ve seen this, why not give it a thumbs up