centos6.X upgrade method python3.X
1. Download
# wget https://www.python.org/ftp/python/3.7.0/Python-3.7.0.tgz
2, extract
# tar -xvf Python-3.7.0.tgz
3, compile, install
# mkdir /usr/local/python3
#yum -y install perl gcc make kernel-headers kernel-devel
# yum -y install libffi-devel
# yum -y install zlib*
# Cd Python-3.7.0
# ./configure --prefix=/usr/local/python3
# make && make install
4, create a new version of Links
# mv /usr/bin/python /usr/bin/python2.6.6
# ln -s /usr/local/python3/bin/python3 /usr/bin/python
# python -V
Python 3.7.0
When installing python3.7 in rhel6 mid-year report the following error
ModuleNotFoundError: No module named '_ctypes' error
is due to a lack libffi-devel lead to open the library, it can be installed by the method
RPM -ivh http://mirror.centos.org/centos /6/os/x86_64/Packages/libffi-devel-3.0.5-3.2.el6.x86_64.rpm
recompile the source code package to install python
yum upgrade python caused abnormal
# yum
File "/usr/bin/yum", line 30
except KeyboardInterrupt, e:
^
SyntaxError: invalid syntax
Reason: This is because the python yum using as a command interpreter, which can be from / usr / bin / yum file in the first line of # / usr / bin / python found!. The compatibility between the python version is not very good, so that there is grammatical inconsistencies between versions 2.X and 3.0 versions. The CentOS 6 comes with yum uses python2.6, when the python system upgrade to 3.0, grammatical interpretation errors.
Solution:
Very simple, first upgrade yum, yum One modification of an interpreter for the old version python2.6 (if you do not upgrade, then mulching)
Yum upgrade approach is not detailed;
Modify yum interpreter for the old version python2.6:
V / Usr / bin / Yom
The first line "#! / Usr / bin / python" was changed to "#! / Usr / bin / python2.6" to