How to install Python3 in CentOS

Source: Internet
Author: User
Tags python script

Linux under the default system comes with python2.6 version, this version is dependent on many programs of the system, so it is not recommended to delete, if using the latest Python3 then we know that the compilation and installation of the source package and the system default package is not any impact, so you can install Python3 and python2 coexistence

First go to the Python official website download Python3 source package, Website: https://www.python.org/

Go in and click on the navigation bar downloads, you can also put the mouse on the downloads pop-up menu to select Source code, is the source code package meaning, Choose the latest version of 3.5.1 here, of course, there are many other historical versions, click on the page below you can see the download link, including the source package, Mac OSX installation package, Windows installation package

  

Here choose the first download, download is the source package: python-3.5.1.tgz, download and upload to the server, start to prepare for installation

Release files:

Tar-xvzf python-3.5.1.tgz

Enter directory:

CD PYTHON-3.5.1/

To add a configuration:

./configure--prefix=/usr/python

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

Make

To perform the installation:

Make install

The entire process is approximately 5-10 minutes, and after the installation is successful, the installation directory is/usr/python

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

We can either delete this or create a new Python3 soft link, except that Python will change to Python3 when executed, or the Python script header declaration will be changed to #!/usr/bin/python3

In order to facilitate the suggestion to rename first, and then create a soft link on it, the previous program head does not have to change:

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

This is established, and then directly execute the Python command, the equivalent of calling Python3, in fact, Python3 is also a soft link, link to python3.5.1, this multiple links actually does not affect, mainly for the version upgrade more convenient, do not change the version number

Python3 new version of the installation is these, do not uninstall the old version, the new version is also normal use

How to install Python3 in CentOS

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.