二. 安装python3.7
本次python3.7使用源码安装
-
安装环境
sudo apt-get install zlib1g-dev libbz2-dev libssl-dev libncurses5-dev libsqlite3-dev libreadline-dev tk-dev libgdbm-dev libdb-dev libpcap-dev xz-utils libexpat1-dev liblzma-dev libffi-dev libc6-dev -
源码安装
2.1下载源码包
从官网下载最新版本源码包并解压
2.2 建立安装目录
sudo mkdir -p /usr/local/python3.7
2.3 编译安装
进入源码包目录下,使用如下命令
./configure --prefix=/usr/local/python3.7 --enable-optimizations
make
sudo make install
如果编译过程中出现如下问题
ModuleNotFoundError: No module named '_ctypes'
Makefile:1130: recipe for target 'install' failed
make: *** [install] Error
可以使用如下方法解决
sudo apt-get update
sudo apt-get upgrade
sudo apt-get dist-upgrade
sudo apt-get install build-essential python-dev python-setuptools python-pip python-smbus
sudo apt-get install build-essential libncursesw5-dev libgdbm-dev libc6-dev
sudo apt-get install zlib1g-dev libsqlite3-dev tk-dev
sudo apt-get install libssl-devopenssl
sudo apt-get install libffi-dev
3 添加软连接
添加python3的软链接
ln -s /usr/local/python3/bin/python3.7 /usr/bin/python3.7
添加 pip3 的软链接
ln -s /usr/local/python3/bin/pip3.7 /usr/bin/pip3.7
4 检测版本
python3.7 -V
pip3.7 -V
作者:55555jacky
链接:https://www.jianshu.com/p/1be92131ab06
来源:简书
著作权归作者所有。商业转载请联系作者获得授权,非商业转载请注明出处。