How does centos install Python3

The default system under Linux comes with a version of python2.6. This version is depended on by many programs in the system, so it is not recommended to delete it. If the latest Python3 is used, then we know that there is no impact between compiling and installing the source package and the system default package. So you can install python3 and python2 to coexist

  First go to the Python official website to download the source package of python3, URL: https: //www.python .org/

  After entering, click Downloads in the navigation bar, or you can place the mouse on the Downloads pop-up menu and select Source code, which means the source code package. Here, select the latest version 3.5.1. Of course, there are many other historical versions below. After clicking in, you can see it at the bottom of the page. To the download link, including the source package, Mac OSX installation package, Windows installation package

  

  Here you can choose the first download. The download is the source package: Python-3.5.1.tgz. After downloading, upload it to the server and start preparing for installation.

  Release files:

tar -xvzf Python-3.5.1.tgz

  Enter the directory:

cd Python-3.5.1 /

  Add configuration:

./configure --prefix=/usr/python

  Configure your own installation directory here, and then compile the source code:

make

  Execute the installation:

make install

  The whole process takes about 5-10 minutes. After the installation is successful, the installation directory is in /usr/python

  The original python in the system is in /usr/bin/python. You can see through ls -l that python is a soft link that links to python2.6 in this directory

  We can delete this, or create a new soft link for python3, but when executing, python should be changed to python3, or the python script header declaration should be changed to #!/usr/bin/python3

  For convenience, it is recommended to rename it first, and then create a soft link. The previous program header does not need to be changed:

$ mv /usr/bin/python /usr/bin/python.bak
$ ln -s /usr/python/bin/python3 /usr/bin/python

  This is established, and executing the python command directly in the future is equivalent to calling python3. In fact, python3 is also a soft link, linking to python3.5.1. This multiple link does not affect it, mainly for the convenience of version upgrade without revision. this number

  This is the installation of the new version of python3, no need to uninstall the old version, the new version is also used normally

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324854712&siteId=291194637