ubuntu安装3.6.5流程如下

1. 下载源码

wget --no-check-certificate https://www.python.org/ftp/python/3.6.5/Python-3.6.5.tgz
tar -xzvf Python-3.6.5.tgz 
cd Python-3.6.5

2.  编译安装

首先安装_ctype依赖,然后才能进行编译安装 

yum install libffi-devel -y

sudo ./configure --prefix=/usr/local/python3.6.5 --with-ssl
sudo make
sudo make install

3. 创建新链接

sudo ln -s /usr/local/Python-3.6.5/python /usr/bin/python

如果安装完之后使用pip的时候如果报下面的错

pip is configured with locations that require TLS/SSL, however the ssl module in Python is not available.

Collecting pandas
  Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError("Can't connect to HTT PS URL because the SSL module is not available.",)': /simple/pandas/


解决方法如下

4. 更新/安装openssl

sudo apt-get install openssl
sudo apt-get install libssl-dev


5. 重新编译安装python3.6

原因为分析:变异安装的时候不加–with-ssl参数时,默认安装的软件涉及到ssl的功能不可用,但是pip用到ssl模块

因此安装的时候需要制定使用ssl

cd Python-3.6.5/
sudo ./configure --prefix=/usr/local/python3.6.5 --with-ssl
sudo make install

解决完毕

顺便上传一个ubuntu的zlib压缩包,国内下载太慢了

zlib源码压缩包


原创文章,转载请注明出处:http://124.221.219.47/article/ubuntu-python/