Linux安装最新Python
操作系统环境
Centos、Rocky
1. 下载最新Python离线安装包
离线包下载
右键复制地址链接
wget
2. 安装最新Python
安装yum依赖
yum install zlib zlib-devel openssl-devel libffi-devel bzip2-devel make gcc -y
解压压缩包
tar -zxvf Python-3.12.0.tgz
编译安装
cd Python-3.12.0/
./configure --with-ssl --prefix=/usr/local/lib/python3.12
make
make install
3. 验证
/usr/local/lib/python3.12/bin/python3 -V
/usr/local/lib/python3.12/bin/pip3 -V
4. 卸载Python
rm -rf /usr/local/lib/python3.12
设置独立virtualenv(venv)环境
1. 安装virtualenv
yum install virtualenv -y
或
pip install virtualenv
个人选择的第一种方式
2. 设置独立venv
/usr/local/lib/python3.12 -m venv datamanageenv
source datamanageenv/bin/activate
验证
3. 在虚拟环境中安装pip依赖包
datamanageenv/bin/python3 -m pip download -d packages/pip confluent_kafka
...
Successfully downloaded confluent_kafka
4. 卸载虚拟环境
rm -rf datamanage