目录
Linux安装最新Python
操作系统环境
1. 下载最新Python离线安装包
2. 安装最新Python
3. 验证
4. 卸载Python
设置独立virtualenv(venv)环境
1. 安装virtualenv
2. 设置独立venv
3. 在虚拟环境中安装pip依赖包
4. 卸载虚拟环境
Centos、Rocky
离线包下载地址
https://www.python.org/downloads
右键复制地址链接
wget https://www.python.org/ftp/python/3.12.0/Python-3.12.0.tgz
安装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
/usr/local/lib/python3.12/bin/python3 -V
/usr/local/lib/python3.12/bin/pip3 -V
rm -rf /usr/local/lib/python3.12
yum install virtualenv -y
或
pip install virtualenv
个人选择的第一种方式
/usr/local/lib/python3.12 -m venv datamanageenv
source datamanageenv/bin/activate
验证
datamanageenv/bin/python3 -m pip download -d packages/pip confluent_kafka
...
Successfully downloaded confluent_kafka
rm -rf datamanage