CENTOS7 build Python3 and coexist with Python2

Source: Internet
Author: User

Note:
1, non-root account plus sudo
2, Centos7 python 2.7.5 can not be uninstalled, many system-level software relies on this

install dependency
# yum-y Groupinstall " Development tools "
# yum-y Install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk- Devel gdbm-devel db4-devel libpcap-devel xz-devel

Download Python3, mine is python-3.4.3.tgz
# wget https:// Www.python.org/ftp/python/3.4.3/Python-3.4.3.tgz
# mkdir/usr/local/python3 
# TAR-ZXVF PYTHON-3.4.3.TGZ
# CD Python-3.4.3
#./configure--prefix=/usr/local/python3
# make && make install
# ln-s/usr/local/python3/bin/python3/usr/bin/python3

ln-s/usr/local/python3/bin/pip3/usr/bin/pip3

Test
View version
# Python3

Python 3.4.3 (Default, Jul 19 2017, 19:29:17)

[GCC 4.8.5 20150623 (Red Hat 4.8.5-11)] on Linux

Type "Help", "copyright", "credits" or "license" for more information.
>>>

>>> exit ()

[Email protected] python-3.4.3]#




Code testing
Create a new Python script in the current directory hello.py
Content:
#!/usr/bin/python3
# first Comment
Print ("Hello, python3!")
Perform
# Python3 hello.py

Hello, python3!.

CENTOS7 build Python3 and coexist with Python2

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.