【Linux】CentOS7安装Python3.8
1 下载Gzipped source tarball
wget https://www.python.org/ftp/python/3.8.13/Python-3.8.13.tgz
2 解压
tar -xzvf Gzipped source tarball
3 安装所需的其他包
yum install -y gcc
4 编译
进入到Python-3.8.12文件下
编译
./configure --prefix=/usr/local/python3.8/Python-3.8.13
make
make失败:
The necessary bits to build these optional modules were not found:
_bz2 _curses _curses_panel
_dbm _gdbm _hashlib
_lzma _sqlite3 _ssl
_tkinter _uuid readline
zlib
To find the necessary bits, look in setup.py in detect_modules() for the module's name.
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
安装所需的包
yum install ncurses-devel
yum install libuuid-devel
yum install -y zlib zlib-devel
yum install sqlite-devel
yum install readline-devel
yum install tkinter
yum -y install tcl-devel tk-devel
yum install lzma
yum install gdbm-devel
yum install xz-devel
yum install libffi-devel
即
yum -y install ncurses-devel libuuid-devel zlib zlib-devel sqlite-devel readline-devel tkinter tcl-devel tk-devel lzma gdbm-devel xz-devel libffi-devel
5 解决ssl问题
wget --no-check-certificate https://ftp.openbsd.org/pub/OpenBSD/LibreSSL/libressl-3.0.2.tar.gz
mkdir /usr/local/libressl
./configure --prefix=/usr/local/libressl
make & make install
# 创建软连接代替openssl
mv /usr/bin/openssl /usr/bin/openssl.bak
mv /usr/include/openssl /usr/include/openssl.bak
ln -s /usr/local/libressl/bin/openssl /usr/bin/openssl
ln -s /usr/local/libressl/include/openssl /usr/include/openssl
echo /usr/local/libressl/lib >> /etc/ld.so.conf.d/libressl-3.0.2.conf
ldconfig -v
# 验证是否安装完成
openssl version
6 重新编译
# 编译前需要设置环境变量
export LDFLAGS="-L/usr/local/libressl/lib"
export CPPFLAGS="-I/usr/local/libressl/include"
export PKG_CONFIG_PATH="/usr/local/libressl/lib/pkgconfig"
./configure --prefix=/usr/local/python3.8/Python-3.8.13
make
make install
7 检查编译是否成功
cd /usr/local/python3.8/Python-3.8.13
cd bin
./python3.8
8 添加环境变量
vi /etc/profile
添加内容
export PYTHON_HOME=/usr/local/python3.8/Python-3.8.13
export PATH=${PYTHON_HOME}/bin:$PATH
环境变量生效
source /etc/profile
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· Manus重磅发布:全球首款通用AI代理技术深度解析与实战指南
· 被坑几百块钱后,我竟然真的恢复了删除的微信聊天记录!
· 没有Manus邀请码?试试免邀请码的MGX或者开源的OpenManus吧
· 园子的第一款AI主题卫衣上架——"HELLO! HOW CAN I ASSIST YOU TODAY
· 【自荐】一款简洁、开源的在线白板工具 Drawnix