1. 源码下载
从https://www.python.org/下载源码。
我这里下载最新的 Python3.7.4。
2. Linux(服务器)版本的Python3.7 编译并安装:
命令如下:
$ tar -xzvf Python-3.7.4.tgz
$ cd Python-3.7.4/
$ mkdir build
$cd build
$../configure --prefix=/usr
$make -j8
$sudo make install
错误1:
Failed to build these modules:
_ctypes
解决:
sudo apt-get install libffi-dev
错误2:
Could not build the ssl module!
Python requires an OpenSSL 1.0.2 or 1.1 compatible libssl with X509_VERIFY_PARAM_set1_host().
LibreSSL 2.6.4 and earlier do not provide the necessary APIs, https://github.com/libressl-portable/portable/issues/381
解决:
下载libressl最新稳定版本 2.7.4
https://ftp.openbsd.org/pub/OpenBSD/LibreSSL/libressl-2.7.4.tar.gz
解压:
tar -xzvf libressl-2.7.4.tar.gz
编译安装:
$ cd libressl-2.7.4
$ ./configure
$ make -j8
$ sudo make