Solve the conflict of multiple versions of python

Solve the conflicts 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 recurring

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 (this is not recommended if you need to use multiple versions for development)

Query the location corresponding to the default python

# Find the execution location of python
which python 
- - /usr/bin/python
# delete
rm /usr/bin/python
# Find the python3 location you need to use. The name is related to the time you follow
which python3
- - /usr/bin/python3 
# Establish soft connection
ln -s /usr/bin/python3 /usr/bin/python
# Check version
python -V
- - python 3.7.9
pip -V
- - pip 20.1.1from/usr/local/python3/lib/python3.7/site-packages/pip(python 3.7)

Re-download requests dependencies

I am here to download the designated mirror. By default, downloading foreign mirrors is slow and often interrupts pip install -i https://pypi.tuna.tsinghua.edu.cn/simple --trusted-host pypi.tuna.tsinghua.edu. cn requests

Start test

Start successfully

This article uses mdnice to typeset

Donate

Recommended Posts

Solve the conflict of multiple versions of python
Solve the conflict of multiple versions of python
Consolidate the foundation of Python(7)
Consolidate the foundation of Python(6)
Solve the problem of python compiling and installing ssl
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
The usage of wheel in python
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?
What are the required parameters of python
Logistic regression at the bottom 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
What are the advantages of python language
The specific method of python instantiation object
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
linux+ubuntu solve python
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?
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
Detailed explanation of the principle of Python function parameter classification
What is the advantage of python over corporate language
A brief summary of the difference between Python2 and Python3
Detailed explanation of the principle of Python timer thread pool
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
How to understand the introduction of packages in Python
Detailed explanation of the attribute access process of Python objects