Linux 离线安装最新Python(3.12)设置独立virtualenv(venv)环境

目录

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

图片[1] - Linux 离线安装最新Python(3.12)设置独立virtualenv(venv)环境 - MaxSSL图片[2] - Linux 离线安装最新Python(3.12)设置独立virtualenv(venv)环境 - MaxSSL

右键复制地址链接

图片[3] - Linux 离线安装最新Python(3.12)设置独立virtualenv(venv)环境 - MaxSSL

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

图片[4] - Linux 离线安装最新Python(3.12)设置独立virtualenv(venv)环境 - MaxSSL

2. 安装最新Python

安装yum依赖

yum install zlib zlib-devel openssl-devel libffi-devel bzip2-devel make gcc -y

解压压缩包

tar -zxvf Python-3.12.0.tgz

图片[5] - Linux 离线安装最新Python(3.12)设置独立virtualenv(venv)环境 - MaxSSL

编译安装

cd Python-3.12.0/./configure --with-ssl --prefix=/usr/local/lib/python3.12makemake install

图片[6] - Linux 离线安装最新Python(3.12)设置独立virtualenv(venv)环境 - MaxSSL

3. 验证

/usr/local/lib/python3.12/bin/python3 -V/usr/local/lib/python3.12/bin/pip3 -V

图片[7] - Linux 离线安装最新Python(3.12)设置独立virtualenv(venv)环境 - MaxSSL

4. 卸载Python

rm -rf /usr/local/lib/python3.12

设置独立virtualenv(venv)环境

1. 安装virtualenv

yum install virtualenv -y或pip install virtualenv 

个人选择的第一种方式

图片[8] - Linux 离线安装最新Python(3.12)设置独立virtualenv(venv)环境 - MaxSSL

2. 设置独立venv

/usr/local/lib/python3.12 -m venv datamanageenvsource datamanageenv/bin/activate

验证

图片[9] - Linux 离线安装最新Python(3.12)设置独立virtualenv(venv)环境 - MaxSSL

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

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

4. 卸载虚拟环境

rm -rf datamanage
© 版权声明
THE END
喜欢就支持一下吧
点赞0 分享