用户工具

站点工具


zh:notes:install_python3.7

Install Python 3.7

Operation System

CentOS 6.8 (64 bits), CentOS 7.6 (64 bits)

Install libffi-devel and zlib-devel

# If this library is not installed ahead, the following exception will be raised. 
# ModuleNotFoundError: No module named '_ctypes'
> yum install libffi-devel
 
# If this library is not installed ahead, the following error will appear. 
# zipimport.ZipImportError: can't decompress data; zlib not available
> yum install zlib-devel
 
# This library should be installed ahead. 
# Otherwise, when pandas package is imported in the python, the following exception will be raised. 
# ModuleNotFoundError: No module named '_bz2'
> yum install  bzip2-devel

Upgrade Python

> wget https://www.python.org/ftp/python/3.7.4/Python-3.7.4.tgz
> tar -zxvf Python-3.7.4.tgz
> rm -f Python-3.7.4.tgz
 
# create the install directory
> mkdir /usr/local/python3.7.4
 
> cd Python-3.7.4
> ./configure --prefix=/usr/local/python3.7.4 --enable-optimizations
> make
> make altinstall
 
# redirect link
> mv /usr/bin/python /usr/bin/python.bak
> ln -s /usr/local/python3.7.4/bin/python3.7 /usr/bin/python
 
# To check the version
> python --version
 
# Edit the shebang lines (first line) of the scripts yum and urlgrabber-ext-down
# Change "#! /usr/bin/python" to "#! /usr/bin/python2"
> vi /usr/bin/yum
> vi /usr/libexec/urlgrabber-ext-down
zh/notes/install_python3.7.txt · 最后更改: 2022/06/30 11:30 由 pzczxs