Install python3.6 under centos7

First, WGet official website downloaded to the local

Entry home directory:cd ~
wget https://www.python.org/ftp/python/3.6.3/Python-3.6.3.tgzDownload to local

Decompression is moved to /usr/lcoal:
tar -zxvf Python-3.6.3.tgz
mv Python-3.6.3 /usr/local/

Installation dependency:
yum install openssl-devel bzip2-devel expat-devel gdbm-devel readline-devel sqlite-devel

Delete old Python soft connection
rm -rf /usr/bin/python

Try to compile and install Python:
cd /usr/local/Python-3.6.3/

To configure:
./configure

Compile:
make

Installation:
make install

Failure to find suitable compiler:

configure: error: in /usr/local/Python-3.6.3': configure: error: no acceptable C compiler found in $PATH Seeconfig.log' for more details

Solve:
yum install gcc-c++

-bash: /usr/bin/yum: /usr/bin/python:bad interpreter no such file or dir

This is because the python soft connection is deleted, while Yum relies on python. So it would be nice to modify the yum file header and call Python to python2.7.
vim /usr/bin/yum File header invocation:
#!/usr/bin/python Change to ——> become /usr/bin/python2.7!

vim /usr/libexec/urlgrabber-ext-down
#! /usr/bin/python2 Change to ———> become /usr/bin/python2.7!

Re execution: installation compiler
yum install gcc-c++

Re execute compilation / installation:
cd /usr/local/Python-3.6.3/

To configure:
./configure

Compile:
make

Installation:
make install

Add Python soft connection again and connect to python3
cd /usr/bin
ln -s /usr/local/bin/python3 python

Execute Python -V to view Python version
python -V

Success

Leave a Reply

Your email address will not be published. Required fields are marked *