linux环境下python安装与卸载--Python2及Python3

一:安装Python

1.python 下载:

Python3:wget  https://www.python.org/ftp/python/3.5.0/Python-3.5.0.tar.xz

Python2:https://www.python.org/ftp/python/2.7.10/Python-2.7.10.tgz

 

2.解压安装包并安装

python3:

tar Jxvf  Python-3.5.0.tar.xz #解压下载的源码包

cd Python-3.5.0  #换到源码包的目录下

./configure --prefix=/opt/python3.5  #说明:指定按装目录:/opt/python3.5

make && make install  #编译并且安装

 

python2:

tar xvf  Python-2.7.10.tgz #解压下载的源码包

cd Python-2.7.10  #换到源码包的目录下

./configure --prefix=/opt/python2.7  #说明:指定按装目录:/opt/python2.7

make && make install  #编译并且安装

3.配置软连接:

#python软连

ln -s  /opt/python3.5/bin/python3.5    /usr/bin/python3

ln -s  /opt/python3.5/bin/pip3   /usr/bin/pip3 

ln -s  /opt/python/bin/python2.7    /usr/bin/python

ln -s  /opt/python2.7/bin/pip   /usr/bin/pip 

4.配置环境变量

vim /etc/profile

       PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin:/opt/python3.5/bin

  保存退出

  读一下这个/etc/profile 使得生效

  source /etc/profile

5.查看python是否安装成功 Python3,如图所示安装成功

linux环境下python安装与卸载--Python2及Python3_第1张图片

 

 

 

补充pip安装:

pip安装:yum -y install python-pip python-wheel

pip升级: pip install --upgrade pip

你可能感兴趣的:(python学习)