The terminal input has been solved before python, Tips /usr/bin/python: The problem of insufficient authority , Now you can install python3.7 了
The following tutorial installs 3.6, Only need to 6 Change to 7 that will do .( Do not delete the system's own python, Otherwise, there will be problems encountered in the previous articles . Once deleted , It's a big deal , The resolution process is too horrible )
from :https://blog.csdn.net/MenciusHometown/article/details/77688728
Ubuntu16.04 The default system comes with python2 and Python3.5 Version of , This version is dependent on many programs in the system , So it is not recommended to delete , If you use the latest Python3.6 Then we know that there is no influence between compiling and installing source code package and system default package .
First go python Download from the official website python3 The source package , website :https://www.python.org/
After you go in, click on the... In the navigation bar Downloads, You can also mouse over Downloads Select... From the pop-up menu Source code, Is the meaning of the source code package , Choose the latest version here 3.6.1, Of course, there are many other historical versions below , After clicking in, you can see the download link at the bottom of the page
choice Download Gzipped source tarball, After downloading it, it will be Python-3.6.1.tgz
Open the terminal , Using commands cd Go to the file folder
Release files
tar xfz Python-3.6.1.tgz
Use here xfz command , It is not recommended to use -xvzf command , Because the folder it releases needs root Permission can be changed or deleted .
Enter the unzipped folder
cd Python-3.6.1/
Add the configuration
./configure --prefix=/usr/local/python3 --enable-optimizations
# make
# sudo make install
To configure is to install Python The folder you need . When the configuration is complete , The terminal will display the following paragraph , You can choose to ignore it , Does not affect subsequent operations .
If you want a release build with all optimizations active (LTO, PGO, etc),
please run ./configure –enable-optimizations
Change the default Python edition
Ubuntu16.04 The version integrates Python2.7 And 3.5 edition , The original in the system python stay /usr/bin/python, adopt ls -l You can see ,python It's a soft link , Link to python3.6
We need to delete the default link first , Let's create another one python3.6 The soft links .
First, make sure that the pointer of the terminal has returned to the root directory , Do the following again
Check the version first , If yes, it proves that the soft link already exists , You need to delete the previous one before you create it again
// This shows that I have python3 Soft links without pip3 So you need to delete python3 The soft link is re established
[email protected]:~/Python-3.7.1$ python3 -V
Python 3.5.2
[email protected]:~$ pip3 -V
bash: /usr/lib/command-not-found: /usr/bin/python3: bad interpreter: No such file or directory
rm -rf /usr/bin/python3
rm -rf /usr/bin/pip3
# add to python3 The soft links
ln -s /usr/local/python3/bin/python3.7 /usr/bin/python3
# add to pip3 The soft links
ln -s /usr/local/python3/bin/pip3.7 /usr/bin/pip3
[email protected]:~$ python3 -V
Python 3.7.1
[email protected]:~$ pip3 -V
pip 10.0.1 from /usr/local/python3/lib/python3.7/site-packages/pip (python 3.7)
1. install pip3:https://blog.csdn.net/weixin_41644725/article/details/87920141
Main steps :
Enter the following command :
cd setuptools-40.8.0
sudo python3.7 setup.py build
sudo python3.7 setup.py install
install pip, Use the following command :
cd pip-19.03
sudo python3.7 setup.py build
sudo python3.7 setup.py install
2. Link switching :https://blog.csdn.net/qq_40965177/article/details/83500817
Main steps :
Input which python3
View the path of shortcut keys .
Address
then cd /usr/bin/
Go to the directory .
rm python3
Create soft link ( My is python3.7, Path in /usr/local/python3/bin Next , So the following python3.6 Change it to /usr/local/python3/bin/python3.7)
ln -s python3.6 python3
python3 -V
( Modify in the same way as above pip3 Link to )