目录

Linux安装最新Python

操作系统环境

1. 下载最新Python离线安装包

2. 安装最新Python

3. 验证

4. 卸载Python

设置独立virtualenv(venv)环境

1. 安装virtualenv

2. 设置独立venv

3. 在虚拟环境中安装pip依赖包

4. 卸载虚拟环境


Linux安装最新Python

操作系统环境

Centos、Rocky

1. 下载最新Python离线安装包

离线包下载地址

https://www.python.org/downloads

右键复制地址链接

wget https://www.python.org/ftp/python/3.12.0/Python-3.12.0.tgz

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.12makemake 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 datamanageenvsource datamanageenv/bin/activate

验证

3. 在虚拟环境中安装pip依赖包

datamanageenv/bin/python3 -m pip download -d packages/pip confluent_kafka...Successfully downloaded confluent_kafka

4. 卸载虚拟环境

rm -rf datamanage