When centos7-mini I used here, centos system itself is installed by default python2.x, version x vary depending on the version of the system, you can view the system comes with python --version version by python or python --V
There are some python2 need to use system commands, can not be uninstalled
1, the installation dependencies
1) First, install gcc compiler, gcc versions of some systems already installed by default, --version viewed by gcc, not installed install gcc, yum -y install gcc
2) install other dependencies, (Note: Do not missing, or they may install python error, python3.7.0 less time to install version libffi-devel)
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 libffi-devel
2, python3.7.0 download the source code, based on demand download
1) In https://www.python.org/ftp/python/ choose their own needs python source package, I downloaded python3.7.0
(You can also go https://www.python.org official website home page to download, find downloads, you can select the version you want to download a)
2) Download
wget https://www.python.org/ftp/python/3.7.0/Python-3.7.0.tgz
3), extract the Python-3.7.0.tgz
tar -zxvf Python-3.7.0.tgz
4, create an empty folder, used to store programs python3
mkdir /usr/local/python3
5, to perform the configuration file, compile, build and install
cd Python-3.7.0 ./configure --prefix=/usr/local/python3 make && make install
No error will be prompted to complete the installation successfully installed
7, establish a flexible connection
ln -s /usr/local/python3/bin/python3.7 /usr/bin/python3 ln -s /usr/local/python3/bin/pip3.7 /usr/bin/pip3
8, can be used to test whether python3
[root@mini Python-3.7.0]# python3 Python 3.7.0 (default, Jul 28 2018, 22:47:29) [GCC 4.8.5 20150623 (Red Hat 4.8.5-28)] on linux Type "help", "copyright", "credits" or "license" for more information. >>> print("hello world!") hello world! >>> exit() [root@mini Python-3.7.0]# pip3 --version pip 10.0.1 from /usr/local/python3/lib/python3.7/site-packages/pip (python 3.7)
Can be used normally see python3.7.0