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.
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
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)
requests
dependenciesI 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 successfully
This article uses mdnice to typeset
Donate
Recommended Posts