0% found this document useful (0 votes)
82 views2 pages

Linux 离线安装python3

Uploaded by

sunchao355
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
82 views2 pages

Linux 离线安装python3

Uploaded by

sunchao355
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

Linux 离线安装 python3.

10
1. 下载 python 源码
https://www.python.org/ftp/python/3.10.9/Python-3.10.8.tar.xz
2. 下载安装 openssl
https://www.openssl.org/source/old/1.1.1/openssl-1.1.1s.tar.gz
tar -xvf openssl-1.1.1s.tar.gz
cd openssl-1.1.1s
./config shared --openssldir=/usr/local/openssl --prefix=/usr/local/openssl
3. 下载安装 gcc-7.5.0+版本
(1) https://mirrors.tuna.tsinghua.edu.cn/gnu/gcc/gcc-9.5.0/gcc-9.5.0.tar.gz
(2) 下载 gcc 依赖包并修改 contrib/download_prerequisites
https://gcc.gnu.org/pub/gcc/infrastructure/gmp-6.2.1.tar.bz2
http://gcc.gnu.org/pub/gcc/infrastructure/mpfr-3.1.4.tar.bz2
http://gcc.gnu.org/pub/gcc/infrastructure/mpc-1.0.3.tar.gz
http://gcc.gnu.org/pub/gcc/infrastructure/isl-0.16.1.tar.bz2
(3) 修改 contrib/download_prerequisites 中的 gmp 版本为 gmp-6.2.1.tar.bz2
(4) 修改 contrib/prerequisites.md5 以及 contrib/prerequisites.sha512
将 prerequisites.md5 中的相应值替换为 md5sum gmp-6.2.1.tar.bz2
将 prerequisites.sha512 中的相应值替换为 sha512sum gmp-6.2.1.tar.bz2

(5) ./contrib/download_prerequisites
(6) ./configure --enable-languages=c,c++ --disable-multilib --with-system-zlib
--prefix=/usr/local/linux_gcc9.5.0
(7) make -j 4
(8) Make install
4. 下载安装依赖库
yum -y install zlib-devel ncurses-devel gdbm-devel xz-devel sqlite-devel tk-devel uuid-devel
readline-devel bzip2-devel libffi-devel
5. 指定 gcc
export CC=/usr/local/linux_gcc9.5.0/bin/gcc
6. 编译
tar -zxvf Python-3.10.9.tar.xz
cd Python-3.10.9
./configure --prefix=/usr/local/python3/ --with-openssl=/usr/local/openssl --with-openssl-
rpath=auto --enable-optimizations --enable-shared
make -j 4
make install
cp /usr/local/python3/lib/libpython3.10.so.1.0 /usr/lib64/
7. 软链接
ln -sf /usr/local/python3/bin/python3 /usr/bin/python3
ln -sf /usr/local/python3/bin/pip3 /usr/bin/pip3
8. 打包
打包后的程序可以上传到其他主机直接运行,不需要再次编译
tar -zcvf python3.10.9.tar.gz /usr/local/python3

参考文献
1. https://baijiahao.baidu.com/s?id=1751626079141000129&wfr=spider&for=pc
2. https://blog.csdn.net/Kaysen_li/article/details/132128620

You might also like