linux安装python教程
解决方法:
我的系统是centos
1、安装依赖库:
yum -y install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gdbm-devel libdb4-devel libpcap-devel xz-devel libffi-devel
2、cd到你要存放文件的目录下载Python源码:
wget https://www.python.org/ftp/python/3.9.0/Python-3.9.0b3.tgz
提示:
先找你要安装的版本https://www.python.org/downloads/source/
我安装的是Python 3.9.0b3 - June 9, 2020
Download Gzipped source tarball
3、当前目录下解压:
tar zxvf Python-3.9.0b3.tgz
4、进入目录:
cd Python-3.9.0b3
5、执行配置(configure shell脚本)生成Makefile(构建文件):
./configure --prefix=/usr/local/python39 --enable-optimizations --with-ssl
6、构建和安装:
make && make install
注意:
报错SystemError: <built-in function compile> returned NULL without setting an error,就 先执行make clean
报错 Could not import runpy module,就去掉--enable-optimizations,再执行make clean,再执第5、6步