Solve the conflict of multiple versions of python

Solve the conflict of multiple versions of python#

Scene analysis##

Generally, the Linux system comes with two versions of python by default. The versions that I follow with the virtual machine system are python2.7 and python3.2, but due to personal habits, I like to use the new version of Python for development. This will cause version conflicts when executing commands.

Problem recurrence###

When I was about to execute a file that I wrote before, an error occurred. It is obvious that the requests dependency is missing, and I will download and install the relevant dependency at this time.

But during the installation, I found that the dependencies I downloaded are stored in the dependency library corresponding to python2.7 by default, that is, after the download is complete, you still hold an error when you execute the python file again, and the related dependency error is not found.

So what we need to solve now is that this relationship does not correspond to the problem

Solve the problem##

Delete the startup file corresponding to the old version (if you need to use multiple versions for development, this is not recommended)

Query the location corresponding to the default python


Find the execution location of python#

which python

delete#

rm /usr/bin/python

Find the python3 location you need to use. The name is related to when you follow it#

which python3

Establish soft connection#

ln -s /usr/bin/python3 /usr/bin/python

Check version#

python -V

pip -V


Re-download requests dependencies###

I am here to download the designated mirror. By default, downloading foreign mirrors is slow and often interrupted.

pip install -i https://pypi.tuna.tsinghua.edu.cn/simple --trusted-host pypi.tuna.tsinghua.edu.cn requests

Start test

Start successfully

Recommended Posts

Solve the conflict of multiple versions of python
Solve the conflict of multiple versions of python
Solve the problem of python running startup error
Consolidate the foundation of Python (4)
Consolidate the foundation of Python(7)
Consolidate the foundation of Python(6)
Solve the problem of python compiling and installing ssl
Consolidate the foundation of Python(5)
Solve the problem of convex hull based on python
Consolidate the foundation of Python (3)
Completely solve the problem of slow downloading of Python packages
Python handles the 4 wheels of Chinese
Python simulation of the landlord deal
What is the use of Python
There are several versions of python
The premise of Python string pooling
Secrets of the new features of Python 3.8
The father of Python joins Microsoft
The operation of python access hdfs
The usage of tuples in python
End the method of running python
Understanding the meaning of rb in python
Can Python implement the structure of the stack?
Learn the basics of python interactive mode
What are the required parameters of python
The usage of Ajax in Python3 crawler
Python solves the Tower of Hanoi game
What is the scope of python variables
Python implements the sum of fractional sequences
Two days of learning the basics of Python
What is the id function of python
Where is the pip path of python3
The essence of Python language: Itertools library
What are the advantages of python language
The specific method of python instantiation object
python3 realizes the function of mask drawing
What is the prospect of python development
What is the function body of python
The specific method of python import library
What is the function of adb in python
Detailed explanation of the principle of Python super() method
The difference between the syntax of java and python
Solve the problem of installing VMwareTools on Ubuntu 18.04
7 features of Python3.9
Python realizes the development of student management system
Python implements the shuffling of the cards in Doudizhu
The meaning and usage of lists in python
Can the value of the python dictionary be modified?
Python implements the source code of the snake game
Detailed explanation of the usage of Python decimal module
How about learning python at the age of 27?
2.1 The Python Interpreter (python interpreter)
The consequences of uninstalling python in ubuntu, very
Solve the problem of installing Theano on Ubuntu19
Python writes the game implementation of fishing master
[898] python get the intersection of two lists | union | difference
What is the advantage of python over corporate language
A brief summary of the difference between Python2 and Python3
Detailed explanation of the implementation steps of Python interface development
How does python call the key of a dictionary
Python crawls the full set of skins of the king pesticide