如何升级到python3版本并且安装pip3

来源:互联网 发布:有声广告制作软件 编辑:程序博客网 时间:2024/05/28 11:48

准备:

Python-3.5.2.tar.xz

pip-8.1.2.tar.gz

setuptools-24.0.2.zip

步骤:

1、自定义编译安装python3.x版本

[html] view plain copy
 在CODE上查看代码片派生到我的代码片
  1. tar Jxf Python-3.5.2.tar.xz  
  2. cd Python-3.5.2  
  3. ./configure --prefix=/usr/local/Python3  
  4. make && make install  

2、安装pip3.x,安装会提示需要setuptools模块,所以需要先安装setuptools模块

[objc] view plain copy
 在CODE上查看代码片派生到我的代码片
  1. tar zxf pip-8.1.2.tar.gz  
  2. tar zxf setuptools-24.0.2.zip  
  3. cd setuptools-24.0.2    
  4. ln -s /usr/local/Python/bin/python3 /usr/bin/python3  
  5. python3 setup.py install  
  6. cd ..  
  7. cd pip-8.1.2  
  8. python3 setup.py install  
  9. ln -s /usr/local/Python3/bin/pip3 /usr/bin/pip3  

3、验证模块是否正常安装

[html] view plain copy
 在CODE上查看代码片派生到我的代码片
  1. python3 -m pip list  
  2.   
  3. decorator (4.0.10)  
  4. ipython (4.2.1)  
  5. ipython-genutils (0.1.0)  
  6. pexpect (4.2.0)  
  7. pickleshare (0.7.2)  
  8. pip (8.1.2)  
  9. ptyprocess (0.5.1)  
  10. setuptools (24.0.2)  
  11. simplegeneric (0.8.1)  
  12. traitlets (4.2.2)  

4、安装ipython

[html] view plain copy
 在CODE上查看代码片派生到我的代码片
  1. python3 -m pip install ipython  
  2. ln -s /usr/local/Python3/bin/ipython3 /usr/bin/ipython3  

5、遇到的问题

a、安装pip3的时候提示没有zlib模块

[html] view plain copy
 在CODE上查看代码片派生到我的代码片
  1. yum install -y zlib-devel  
  2. ./configure; echo $? ; make && make install  

b、使用pip3的时候提示没有HTTPSHandler模块,提示信息如下,

ImportError: cannot import name 'HTTPSHandler

[html] view plain copy
 在CODE上查看代码片派生到我的代码片
  1. yum install -y openssl-devel  

然后再重新编译安装python3就可以了,安装完成后就可以直接使用pip3了,不需要再重新编译安装pip3


原创粉丝点击