Centos7-python2与python3共存

W.r 233 次浏览 0

因环境需要Python2与Python共存,折腾下centos.记录以备日后需要!

centos7默认自带python2.7与pip2

0x1 编译安装python3

wget https://www.python.org/ftp/python/3.7.1/Python-3.7.1.tgz

tar zxvf Python-3.7.1.tgz

cd Python-3.7.1

./configure prefix=/usr/local/python3

make&&make install

0x2 错误记录

1.zipimport.ZipImportError: can't decompress data; zlib not available

安装依赖zlib、zlib-devel
yum install zlib zlib-devel -y

2.ModuleNotFoundError: No module named '_ctypes'

3.7版本需要一个新的包 libffi-devel
yum install libffi-devel -y

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

缺少ssl模块
yum install openssl-devel -y 
重新编译
./configure --with-ssl
make&&make install

软链

cd /usr/local/python3/bin/
ln -s /usr/local/python3/bin/python3.7 /usr/bin/python3
ln -s /usr/local/python3/bin/pip3 /usr/bin/pip3

最后 pip3 --version python3 --version

发表评论 取消回复
表情