CentOS 6 compile and install python 3

Python official website: https://www.python.org/

1. Check the CentOS version and the system default Python version:

cat /etc/redhat-release

python -V

**2. Compile and install Python-3.6.1: **

1、 Install dependent packages:

yum -y groupinstall "Development tools"

yum -y install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-develreadline-devel tk-devel gdbm-devel db4-devel libpcap-devel xz-devel

2、 Set the current system time of CentOS6:

date 040413022017.30

date

3、 Compile and install Python-3.6.1:

wget https://www.python.org/ftp/python/3.6.1/Python-3.6.1.tar.xz

tar xf Python-3.6.1.tar.xz -C /usr/src

cd /usr/src/Python-3.6.1

. /configure --prefix=/usr/local/python3.6.1 --enable-shared --enable-profiling--enable-optimizations --disable-ipv6 --with-threads --with-pymalloc --with-fpectl--enable-loadable-sqlite-extensions

make && make install //In this step, a test needs to be performed, which takes a long time

4、 Change the default Python version of CentOS6 to 3.6.1:

mv /usr/bin/python /usr/bin/python2.6.6-old

ln -s /usr/local/python3.6.1/bin/python3 /usr/bin/python

5、 Add to the PATH environment variable:

vim /etc/profile.d/python3.6.1.sh

exportPATH=/usr/local/python3.6.1/bin:$PATH

. /etc/profile.d/python3.6.1.sh

echo $PATH

6、 Configuration header file:

ln -sv /usr/local/python3.6.1/include /usr/include/python3.6

7、 Configuration library file:

echo "/usr/local/python3.6.1/lib" >/etc/ld.so.conf.d/python3.6.1.conf

cat /etc/ld.so.conf.d/python3.6.1.conf

ldconfig

8、 Configure man help files:

vim /etc/man.config, add the following code:

MANPATH /usr/local/python3.6.1/share/man

9、 View the configured Python version:

python -V

python3 -V

3. Modify the Python version in yum to the original 2.6.6 version of the system:

After upgrading Python, yum cannot be used:

vim /usr/bin/yum, modify the "#!/usr/bin/python" in the first line to "#!/usr/bin/python2.6.6-old"

Added: install pip method

First install the epel extension source:

# yum -y install epel-release
Then install pip

yum -y install python-pip

centos find command

find /-name "pip*"

1、 Install python3.6.1

2、 Install setuptools35.0.2

3、 Install pip

easy_install pip

This article is from the "天道救勤" blog, please keep this source http://qiuyue.blog.51cto.com/1246073/1912806

Recommended Posts

CentOS 6.9 compile and install python
CentOS 6 compile and install python 3
centos7 install python3 and ipython
CentOs7.3 compile and install Nginx 1.9.9
ubuntu18.04 compile and install python3.8
Centos compile and install Git
CentOS7 install python3 and pip3
Centos7 compile and install ntp-4.2.8p11
Centos6 install Python2.7.13
Centos7 install Python 3.6.
CentOS install Python 3.6
Centos7 install Python2.7
Centos install Python3
CentOS6.8 install python2.7
CentOS Yum compile and install MySQL 5.6
Compile and install LAMP under Centos 5.2
CentOS 6.x compile and install Nginx
CentOS7 compile and install L(A|N)MP environment
CentOS quickly install Python3 and pip3
Install Python3 and ansible under CentOS8
Install Python3 and Py under CentOS7
Linux CentOS6 compile and install Pyt
Compile and install libmodbus library under CentOS7
CentOS7.5 source code compile and install mysql5.7.29
Centos7 compile and install MySQL8 problem record
Compile and install nodejs and yum in Centos8
CentOS7.4 source code compile and install MySQL8.0
Centos6.5 compile and install LNMP architecture web environment
Centos7.2 compile and install way to build phpMyAdmin
Know Linux and install CentOS
CentOS 7 install Mono and MonoDevelop
Ubuntu 16.04 compile and install PHP 7.2
CentOS6.5 install Java 8 and Tomcat8
Centos 6.10 reinstall python and yum
Centos6.5 install and configure mongodb
CentOS7 install OracleJDK and JRE
CentOS6.5 install Java 8 and Tomcat8
CentOS6 install and crack Jira 7
CentOS6.5 install Java 8 and Tomcat8
Centos6 install python3 pip3 ipython3
CentOS6 install and crack Jira 7
CentOS + Python3.6+
Centos compile and install LAMP (apache-2.4.7 + mysql-5.5.35 + php 5.5.8) + Redis
1.5 Install Centos7
Compile and install Lnmp shell script under Linux centos
Centos 7.5 python3.6
CentOS7 yum install and start mysql
Install and configure keepalived under CentOS 5.9
CentOS 8 install Git and basic configuration
How to install Python 3.8 on CentOS 8
CentOS7 yum install and start mysql
Centos7 and centos8 install mysql5.6 5.7 8.0 so simple
Centos7 uninstall openJdk, and install JDK1.8
Install and use docker under CentOS 6.8
CentOS7 install and use SQL Server
CentOS Minimal install and configure TIPS
Install and configure FreeIPA in Centos7
Compile and install QEMU under Ubuntu
virtualBox install centos, and build tomcat
Install Mono 3.2 and Jexus 5.4 under CentOS 6.3
Compile and install the open source EDA tool-Surelog on CentOS8