linux下 python 版本查看和修改

1.linux的软连接存放位置

cd /usr/bin

2.查看现有python的软连接指向的版本

ls -al *python*

3.删除旧的软连接

rm python

4.建立新的软连接

ln -s python3.6 python

5.查看软连接版本

python -V

全部操作都在root用户下执行

1.安装编译相关工具
yum -y groupinstall "Development tools"
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
yum install libffi-devel -y

2.下载安装包解压

cd #回到用户目录
wget https://www.python.org/ftp/python/3.7.0/Python-3.7.0.tar.xz
tar -xvJf Python-3.7.0.tar.xz

3.编译安装

mkdir /usr/local/python3 #创建编译安装目录
cd Python-3.7.0
./configure --prefix=/usr/local/python3
make && make install


4.创建软连接

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


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

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

5.验证是否成功
python3 -V
pip3 -V



posted @ 2021-02-25 15:32  一颗大白鲸  阅读(3987)  评论(0编辑  收藏  举报