Resolve multiple versions of Python conflicts
Scenario analysis
Most Linux systems come with two versions of Python by default. I used python2.7 and Python 3.2 on my vm system, but due to personal habits, I prefer to use newer versions of Python for development. This can cause version conflicts when executing commands.
Problem of repetition
An error occurred when I was about to execute a file I had written earlier. What is obvious is the lackrequests
Dependencies, at which point I download and install the dependencies.
But when I installed it, I found that the dependencies I downloaded were stored by defaultpython2.7
In the corresponding dependency library, after the download is complete, you execute againpython
File is still wrong, no dependency error found
So what we need to solve now is the problem that this relationship does not correspond
To solve the problem
Delete the startup file corresponding to the old version (this is not recommended if you need to use multiple versions)
Query the location of the default Python
Find where python is executed
which python
-- /usr/bin/python
# remove
rm /usr/bin/python
The name is dependent on when you choose to use python3 which python3 -- /usr/bin/python3 Create a soft connection ln -s /usr/bin/python3 /usr/bin/python # check version python -V - python 3.7.9pip -V -- pip 20.1.1 from /usr/local/ python3 / lib/python3.7 / site - packages/PIP (python 3.7)Copy the code
To downloadrequests
Rely on
I am here to specify the image download, the default download foreign image is slow, often interruptedpip install -i https://pypi.tuna.tsinghua.edu.cn/simple --trusted-host pypi.tuna.tsinghua.edu.cn requests
Start the test
Start-up success
This article is formatted using MDNICE