centos7 安装python3.12.5
目录
1、安装openssl
1.1安装之前需要把本地openssl版本更新
1.2配置并编译安装
1.3安装后把本地的openssl备份一下
1.4添加环境变量
1.5刷新文件&&查看openssl版本
1.6配置新版的软连接
1.7 更新共享库的链接器缓存
2、安装Python3.12.5
2.1python3.12.5安装
2.2配置&&编译并安装
2.3配置环境变量
2.4测试python3
centos7安装python3.12.5,0报错安装 你们可能会有一些软件包依赖问题,可自行下载相关依赖包
1、安装openssl
1.1安装之前需要把本地openssl版本更新
openssl 下载地址
[root@ces-235 openssl-1.1.1w]# openssl version
OpenSSL 1.0.2k-fips 26 Jan 2017
[root@ces-235 ope]# tar -xvf openssl-1.1.1w.tar.gz -C /usr/local/
[root@ces-235 ope]# cd /usr/local/openssl-1.1.1w/
1.2配置并编译安装
[root@ces-235 openssl-1.1.1w]# ./config --prefix=/usr/local/openssl shared
Operating system: x86_64-whatever-linux2
Configuring OpenSSL version 1.1.1w (0x1010117fL) for linux-x86_64
Using os-specific seed configuration
Creating configdata.pm
Creating Makefile
**********************************************************************
*** ***
*** OpenSSL has been successfully configured ***
*** ***
*** If you encounter a problem while building, please open an ***
*** issue on GitHub <https://github.com/openssl/openssl/issues> ***
*** and include the output from the following command: ***
*** ***
*** perl configdata.pm --dump ***
*** ***
*** (If you are new to OpenSSL, you might want to consult the ***
*** 'Troubleshooting' section in the INSTALL file first) ***
*** ***
**********************************************************************
[root@ces-235 openssl-1.1.1w]# make && make install
1.3安装后把本地的openssl备份一下
[root@ces-235 openssl-1.1.1w]# mv /usr/bin/openssl /usr/bin/openssl.back
1.4添加环境变量
vim /root/.bashrc
export LD_LIBRARY_PATH=/usr/local/openssl/lib:$LD_LIBRARY_PATH
[root@ces-235 openssl-1.1.1w]# cat /root/.bashrc
# .bashrc
# User specific aliases and functions
alias rm='rm -i'
alias cp='cp -i'
alias mv='mv -i'
# Source global definitions
if [ -f /etc/bashrc ]; then
. /etc/bashrc
fi
export LD_LIBRARY_PATH=/usr/local/openssl/lib:$LD_LIBRARY_PATH
1.5刷新文件&&查看openssl版本
[root@ces-235 openssl-1.1.1w]# source /root/.bashrc
[root@ces-235 openssl-1.1.1w]# /usr/local/openssl/bin/openssl version
OpenSSL 1.1.1w 11 Sep 2023
1.6配置新版的软连接
[root@ces-235 openssl-1.1.1w]# ln -s /usr/local/openssl/bin/openssl /usr/bin/openssl
[root@ces-235 openssl-1.1.1w]# openssl version
OpenSSL 1.1.1w 11 Sep 2023
1.7 更新共享库的链接器缓存
[root@ces-235 openssl-1.1.1w]# ldconfig
[root@ces-235 openssl-1.1.1w]# openssl version
OpenSSL 1.1.1w 11 Sep 2023
2、安装Python3.12.5
2.1python3.12.5安装
python 下载地址
[root@ces-235 src]# tar -xvf Python-3.12.5.tgz -C /usr/local/
[root@ces-235 src]# cd /usr/local/Python-3.12.5/
2.2配置&&编译并安装
[root@ces-235 Python-3.12.5]# ./configure --prefix=/usr/local/python3.12 --with-openssl=/usr/local/openssl
[root@ces-235 Python-3.12.5]# make && make install
最后有这样的安装完成提示
if test "x" != "x" ; then \
rm -f /usr/local/python3.12/bin/python3-32; \
(cd /usr/local/python3.12/bin; ln -s python3.12-32 python3-32) \
fi
if test "x" != "x" ; then \
rm -f /usr/local/python3.12/bin/python3-intel64; \
(cd /usr/local/python3.12/bin; ln -s python3.12-intel64 python3-intel64) \
fi
rm -f /usr/local/python3.12/share/man/man1/python3.1
(cd /usr/local/python3.12/share/man/man1; ln -s python3.12.1 python3.1)
if test "xupgrade" != "xno" ; then \
case upgrade in \
upgrade) ensurepip="--upgrade" ;; \
install|*) ensurepip="" ;; \
esac; \
./python -E -m ensurepip \
$ensurepip --root=/ ; \
fi
Looking in links: /tmp/tmpzke478ih
Processing /tmp/tmpzke478ih/pip-24.2-py3-none-any.whl
Installing collected packages: pip
WARNING: The scripts pip3 and pip3.12 are installed in '/usr/local/python3.12/bin' which is not on PATH.
Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
Successfully installed pip-24.2
WARNING: Running pip as the 'root' user can result in broken permissions and conflicting behaviour with the system package manager, possibly rendering your system unusable.It is recommended to use a virtual environment instead: https://pip.pypa.io/warnings/venv. Use the --root-user-action option if you know what you are doing and want to suppress this warning.
2.3配置环境变量
export PATH="/usr/local/python3.12/bin:$PATH"
[root@ces-235 Python-3.12.5]# cat /root/.bashrc
# .bashrc
# User specific aliases and functions
alias rm='rm -i'
alias cp='cp -i'
alias mv='mv -i'
# Source global definitions
if [ -f /etc/bashrc ]; then
. /etc/bashrc
fi
export LD_LIBRARY_PATH=/usr/local/openssl/lib:$LD_LIBRARY_PATH
export PATH="/usr/local/python3.12/bin:$PATH"
[root@ces-235 Python-3.12.5]#
[root@ces-235 Python-3.12.5]# source /root/.bashrc
2.4测试python3
[root@ces-235 Python-3.12.5]# pip3 install flask
Collecting flask
Using cached flask-3.0.3-py3-none-any.whl.metadata (3.2 kB)
Collecting Werkzeug>=3.0.0 (from flask)
Using cached werkzeug-3.0.4-py3-none-any.whl.metadata (3.7 kB)Collecting Jinja2>=3.1.2 (from flask)
Downloading jinja2-3.1.4-py3-none-any.whl.metadata (2.6 kB)
Collecting itsdangerous>=2.1.2 (from flask)
Downloading itsdangerous-2.2.0-py3-none-any.whl.metadata (1.9 kB)
centos7安装python3.12.5,0报错安装 你们可能会有一些软件包依赖问题,可自行下载相关依赖包