源码编译安装 python3
源码安装 python3
-
安装编译器与依赖
1
2
3yum -y install gcc openssl-devel
#安装make需要的依赖包:
yum -y install zlib-devel bzip2-devel ncurses-devel libffi-devel -
下载源码包并解压
wget https://www.python.org/ftp/python/3.8.10/Python-3.8.10.tar.xz
tar xf Python-3.8.10.tar.xz
-
进入解压后的文件夹中,编译和安装
1
2
3cd Python-3.8.10
./configure --prefix=/usr/local/python3
make && makeinstall -
建立软链接
1
2ln -s /usr/local/python3/bin/python3 /usr/bin/python3
ln -s /usr/local/python3/bin/pip3 /usr/bin/pip3 -
验证
1
2python3 -V
pip3 -V
一些常见问题
- subprocess.CalledProcessError: Command ‘(‘lsb_release’, ‘-a’)’ returned non-zero exit status 1.
find / -name lsb_release|xargs rm -f