本篇文章介绍linux环境下安装python。
下载地址:官方网站
我们以最新的标准版为例
yum -y install openssl-devel ncurses-devel libffi-devel zlib-devel
tar -zxvf Python-3.12.1.tgz
mkdir /usr/local/python
cd Python-3.12.1
./configure --prefix=/usr/local/python --enable-unicode=ucs4 --enable-shared --enable-optimizations --with-ssl
make && make install
操作系统自带pythone2版本,此处作用为2和3版本同时存在
ln -s /usr/local/python/bin/python3 /usr/bin/python3
ln -s /usr/local/python/bin/pip3 /usr/bin/pip3
python3 -V
pip3 -V
回到顶部
如果遇到以下错误:
./python3: error while loading shared libraries: libpython3.12.so.1.0: cannot open shared object file: No such file or directory
vi /etc/profile
export LD_LIBRARY_PATH=/usr/local/python/lib:$LD_LIBRARY_PATH
source /etc/profile