目 录CONTENT

文章目录

Linux如何安装Python

chenming
2021-07-21 / 0 评论 / 0 点赞 / 187 阅读 / 0 字 / 正在检测是否收录...

安装步骤

编译环境

安装python前必须要安装一下gcc、openssl等环境

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

下载并解压

wget http://npm.taobao.org/mirrors/python/3.9.0/Python-3.9.0.tgz
# 或
wget https://www.python.org/ftp/python/3.9.0/Python-3.9.0.tgz
tar -zxvf Python-3.9.0.tgz

编译并安装

进入解压后的文件夹

./configure --prefix=/opt/python3.9
make
make install

建立软链接

# 一般docker的centos镜像里面预装好了低版本的python,-f参数是强制创建软连接,也就是覆盖
ln -sf /opt/python3.9/bin/python3 /usr/bin/python3
ln -s /opt/python3.9/bin/pip3 /usr/bin/pip3

一般高版本的python都自带pip,需要twine可以用pip进行安装

0

评论区