1、linux下安装python3
a、 准备编译环境(环境如果不对的话,可能遇到各种问题,比如wget无法下载https链接的文件)
1
2
|
yum groupinstall
'Development Tools'
yum install zlib-devel bzip2-devel openssl-devel ncurses-devel
|
2 下载 Python3.5代码包
wget https://www.python.org/ftp/python/3.5.0/Python-3.5.0.tar.xz
在安装包中有一个README的文件,里面有写如何安装
tar Jxvf Python-3.5.0.tar.xz cd Python-3.5.0 ./configure --prefix=/usr/local/python3 make && make install
做软链:
ln -s /usr/local/python3/bin/python3.5 /usr/local/bin/python3
安装成功了!
如果提示:Ignoring ensurepip failure: pip 7.1.2 requires SSL/TLS
这是原因没有安装或升级oenssl:
yum install openssl-devel
再次重复编译方案python3.5:
最终如下:
提示同时成功安装pip-7.12与setuptools!
pip3与pip都提示没有错误!
做软链:
ln -s /usr/local/python3/bin/pip3.5 /usr/local/bin/pip
ln -s /usr/local/python3/bin/easy_install /usr/local/bin/easy_install
升级pip到最新版本:
pip install --upgrade pip
pip安装成功啦!