Installing python3.x on Centos 7

Source: Internet
Author: User

Centos7 default installation is 2.7, here choose to install using Python3.6.3

Installing Python3.6.3

1, install the Python3 need to rely on the package

Yum install-y openssl-devel bzip2-devel expat-devel gdbm-devel readline-devel sqlite-devel gcc cc

2. Download Python source code

wget https://www.python.org/ftp/python/3.6.3/Python-3.6.3.tgz

3. Unzip and compile

Mkdir/usr/local/python3-Ptar XF python-3.6.3. TGZCD python-3.6.3. /configure--prefix=/usr/local/python3makemake Install

4. Back up the old version of Python soft link, link the new version of Python

[[Email protected] ~] # ls-l/usr/bin/pythonlrwxrwxrwx. 1 root root 9 Oct 14:08/usr/bin/python~]#  ls-l/usr/bin/python2lrwxrwxrwx. 1 root root 9 Oct 14:08/usr/bin/python2-python2.7~]#  ls-l/usr/bin/python2.7-RWXR-XR -X. 1 root root 7136  5  2016/usr/bin/python2.7

mv/usr/bin/python/usr/bin/-s/usr/local/python3/bin/python3/usr/bin/-s/usr/local/python3/bin/ Pip3/usr/bin/pip

5. Modify the Yum configuration file

vim/usr/bin//usr/libexec/urlgrabber-ext-down

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

6. Check Python and PIP version

[[Email protected] ~] # python-v Python 3.6.3~]#  pip-v from/usr/local/python3/lib/python3.6/site-packages ( Python 3.6)

Reference Original Address: HTTP://MP.WEIXIN.QQ.COM/S/9FLUQSWADWKYAUMYIXF8DW (provides another way of coexistence)

Installing python3.x on Centos 7

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.