CentOS7 install Python 3.6

Installation database environment before python, very important

yum install gcc patch libffi-devel python-devel  zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gdbm-devel db4-devel libpcap-devel xz-devel -y

Begin installing Python 3.6.6

# Create an installation package directory, you want to change the 3.6.6 version can be

mkdir -p /root/Downloads && cd /root/Downloads

# Download

wget https://www.python.org/ftp/python/3.6.0/Python-3.6.0.tgz

# Extract the source package

tar -zxvf Python-3.6.6.tgz

# Create the installation directory

mkdir /usr/local/python3

# Into the installation package

cd Python-3.6.6

# Install to the specified directory

./configure --prefix=/usr/local/python3

# Compiler

make && make install

# Patience installation is complete ..

Join the global environment variables

python3.6.6 default did not add path, in / etc / profile last line add

 

vi / etc / profile

 

add people

export PATH=$PATH:/usr/local/python3/bin

then

source /etc/profile

Or use a soft link ways: as follows

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

It can be used globally successful python3 latter two methods

Problem:

yum package management is to use python2.x written, will python2.x upgrade to python3.1.3 later, because the python version syntax compatibility cause problems
Solution:
Open the yum configuration file

# V / Usr / bin / Yom

, Pointing to the python previous version of the old version

#!/usr/bin/python2.7

Open urlgrabber-ext-down file

# vi /usr/libexec/urlgrabber-ext-down

Change the python version

#!/usr/bin/python2.7

Guess you like

Origin www.cnblogs.com/adidasshe/p/11904720.html
Recommended