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