CentOs6.5 comes with python2.6.6 by default, and many packages cannot be used for the built-in version, such as the ORM of the database. There are also some projects that may use the python version, and will no longer support Python2.x in the future. It mainly introduces the source code installation of python3.6.1 on CentOs.
Most of this article refers to installing python3 from the source code , but the original text is more troublesome. After simplification, it is mainly the following steps.
Step 1: Install dependency packages (more important)
yum install -y openssl-static # may be valid for pip3
yum install -y gcc wget #install gcc
yum groupinstall "Development tools"
yum install zlib-devel
yum install openssl-devel
Step 2: Download the source code, unzip it, enter the directory, and create a directory
wget https://www.python.org/ftp/python/3.6.1/Python-3.6.1.tgz
tar zxvf Python-3.6.1
cd Python-3.6.1
mkdir /usr/local/python3
Step 3: Compile and install (note that switch to root here, that is, su root instead of sudo)
./configure --prefix=/usr/local/python3 #If you do not specify a directory, it will be installed in /usr/local/bin, /usr/local/lib, /usr/local/share by default, so it is not easy to delete
make && make install #Wait patiently
Step 4: Set environment variables and create soft links
vim /etc/profile
Add export $PATH="/usr/local/python3/bin:$PATH" at the end
ln -s /usr/local/python3/bin/python3 /usr/bin/python3
At this point, the installation is complete. Enter python3 in the terminal to enter the interactive interface. Entering pip3 -V will output version information
Reference:
https://www.cnblogs.com/weifeng1463/p/7883765.html