CentOS安装Python
安装python3.5.2
复杂安装(亲身测试)
- 编译环境的安装:yum install zlib-devel bzip2-devel openssl-devel ncurese-devel(要先安装这个不然python安装不完整,会没有pip3)
- cd ~/下载
- wget https://www.python.org/ftp/python/3.5.2/Python-3.5.2.tgz
- tar -xf Python-3.5.2.tgz
- cd ~/下载/Python-3.5.2
- 设置安装目录:./configure --prefix=/usr/bin/python-3.5.2
- 新建安装的文件夹:sudo mkdir /usr/bin/python-3.5.2
- 编译命令 :make(等待..)
- 安装命令:sudo make install
- 修改默认的python:
-
- sudo mv /usr/bin/python /usr/bin/python.bak
-
- sudo ln -s /usr/bin/python-3.5.2/bin/python3.5 /usr/bin/python
- 查看默认版本:python -V
- 更改yum配置:sudo vi /usr/bin/yum(更改头部的python为python.bak)这样yum又可以使用python2
- pip3使用前配置:ln -s /usr/bin/python-3.5.2/bin/pip3 /usr/bin/pip3
- 输入pip3 list,查看是否可以运行
- pip3升级:pip3 install --upgrade pip
简单安装(没试验过)
- 先安装epel源:yum install epel-release(如果改了默认python版本,则sudo vi /usr/libexec/urlgrabber-ext-down,把python改为python.bak,否则会出错)
- yum install python35
- yum install python35-setuptools
- easy_install-3.4 pip
安装python2的pip:sudo yum -y install python-pip(前提:已经先安装epel源)
卸载python
- 如果是像上面这样源码安装,直接删除/usr/bin/python-3.5.2 文件夹即可
- 如果是yum安装:yum装的用rpm -e 卸载,具体百度查(没试过)