linux centos 安装python

1.安装依赖包

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

2.下载python安装包

python版本可以自己指定

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

3.解压python安装包

tar -zxvf Python-3.9.7.tgz -C .

4.安装python

指定Python 安装的目标路径为/user/local/python3

cd Python-3.9.7
./configure --prefix=/usr/local/python3

将 Python 安装到系统中

make && make install

5.建立python软链接

如果软链接存在,删除即可

ln -s /usr/local/python3/bin/python3.9 /usr/bin/python
ln -s /usr/local/python3/bin/python3.9 /usr/bin/python3
ln -s /usr/local/python3/bin/pip3.9 /usr/bin/pip

你可能感兴趣的:(linux,python)