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

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

准备:

Python-3.5.2.tar.xz

pip-8.1.2.tar.gz

setuptools-24.0.2.zip

步骤:

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

tar Jxf Python-3.5.2.tar.xz
cd Python-3.5.2
./configure --prefix=/usr/local/Python3
make && make install

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

tar zxf pip-8.1.2.tar.gz
tar zxf setuptools-24.0.2.zip
cd setuptools-24.0.2  
ln -s /usr/local/Python/bin/python3 /usr/bin/python3
python3 setup.py install
cd ..
cd pip-8.1.2
python3 setup.py install
ln -s /usr/local/Python3/bin/pip3 /usr/bin/pip3

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

python3 -m pip list

decorator (4.0.10)
ipython (4.2.1)
ipython-genutils (0.1.0)
pexpect (4.2.0)
pickleshare (0.7.2)
pip (8.1.2)
ptyprocess (0.5.1)
setuptools (24.0.2)
simplegeneric (0.8.1)
traitlets (4.2.2)

4、安装ipython

python3 -m pip install ipython
ln -s /usr/local/Python3/bin/ipython3 /usr/bin/ipython3

5、遇到的问题

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

yum install -y zlib-devel
./configure; echo $? ; make && make install

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

ImportError: cannot import name 'HTTPSHandler

yum install -y openssl-devel

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


 

你可能感兴趣的:(python)