CentOS 7 installs Python3.5 and is compatible with Python2.7

Source: Internet
Author: User

CentOS7 installed by default python2.7.5, when you need to use Python3, you can manually download the Python source code after compiling the installation.

1. The dependencies that may be used to install python3.5

1 yum install openssl-devel bzip2-devel expat-devel gdbm-devel readline-devel sqlite-devel



2. Download Python

wget "Https://www.python.org/ftp/python/3.5.0/Python-3.5.0.tgz"

3. Unzip the downloaded compressed package

TAR-ZXVF python-3.5.0.tgz

4. Configuring the Compilation

1 sudo mkdir/usr/local/python3
2 sudo python-3.5.0/configure--prefix=/usr/local/python3
3 sudo make
4 sudo make install

5. Back up the old version of Python, link the new version of Python

In/usr/bin python, Python2, python2.7 three files pointing to the latter

1 sudo mv Python python.bak,
2 sudo ln-s/usr/local/python3/bin/python3/usr/bin/python

6. Modifying the Yum configuration file

sudo vi/usr/bin/yum

Change the python version specified in the first line to python2.7 (#!/usr/bin/python to #!/usr/bin/python2.7)

CentOS 7 installs Python3.5 and is compatible with Python2.7

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.