新安装的centos7中没有Python3环境 本来准备用yum安装的省时省力,发现yum默认的源里面Python3比较老,所以准备源码安装。
在官网下载包以后,编译安装,本来觉得应该很顺利,安装下来发现还是有些依赖库,为以后避免重复入坑,特此记录下。
环境:
$ uname -a
Linux bogon 3.10.0-514.26.2.el7.x86_64 #1 SMP Tue Jul 4 15:04:05 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux
$ cat /etc/redhat-release
CentOS Linux release 7.3.1611 (Core)
首先下载最新版Python源码,执行:
wget https://www.python.org/ftp/python/3.6.1/Python-3.6.1.tar.xz
$ ./configure
$ make
$ sudo make install
make的时候报错:
zipimport.ZipImportError: can't decompress data; zlib not available
make: *** [install] Error 1
处理方式 安装zlib:
sudo yum install -y zlib*
继续编译安装完成,可以看到 pip 也一起安装了
但是在执行pip3 install 的时候报错:
sudo pip3 install beautifulsoup4
pip is configured with locations that require TLS/SSL, however the ssl module in Python is not available.
Collecting beautifulsoup4
Could not fetch URL https://pypi.python.org/simple/beautifulsoup4/: There was a problem confirming the ssl certificate: Can't connect to HTTPS URL because the SSL module is not available. - skipping
Could not find a version that satisfies the requirement beautifulsoup4 (from versions: )
No matching distribution found for beautifulsoup4
提示找不到ssl模块,查看openssl安装包,发现缺少openssl-devel包
$rpm -aq|grep openssl
sudo yum install openssl
重新编译 Python-3.6.1.
再执行
$sudo pip3 install beautifulsoup4
[sudo] password for ***:
Collecting beautifulsoup4
Downloading beautifulsoup4-4.6.0-py3-none-any.whl (86kB)
100% |████████████████████████████████| 92kB 220kB/s
Installing collected packages: beautifulsoup4
Successfully installed beautifulsoup4-4.6.0
安装成功.
Done.