Centos 7 安装 Python3.9.16

下载地址:https://www.python.org/ftp/python

1、下载Python官网(https://www.python.org/downloads/)对应的安装包,选择3.9.16的linux版本

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

2、解压tgz包

tar zxvf Python-3.9.16.tgz -C /opt

3、创建Python3安装目录

mkdir /usr/local/python3

4、安装依赖包

yum install -y gcc zlib* zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gdbm-devel db4-devel libpcap-devel xz-devel libffi-devel

5、配置安装路径。注意:openssl提前装好

cd /opt/Python-3.9.16/
./configure --prefix=/usr/local/python3 --with-openssl=/usr/local/openssl

6、编译

make -j

7、安装

make install -j

8、建立软链接

ln -s /usr/local/python3/bin/python3 /usr/bin/python3
ln
-s /usr/local/python3/bin/pip3 /usr/bin/pip3

9、修改配置文件/etc/profile,增加以下内容:

PATH=$PATH:/usr/local/python3/bin

执行语句source /etc/profile使环境变量配置立即生效

 10、设置 pip3 为清华源

pip3 config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple

11、确认源地址

pip3 config list | grep global.index-url

 

 

 

 
制作安装
posted @ 2023-04-09 14:15  苦逼yw  阅读(369)  评论(0编辑  收藏  举报