在centos6上安装python3.7以及一大堆垃圾问题安装

一.安装

1.wget下载python3.7。

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

2.配置 && 编译安装python

./configure --prefix=/usr/local/python3 --with-openssl=/usr/local/openssl/
make && make install

3.软连接命令

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

4.执行python3.发现以下结果为正常

二.安装过程中的一堆坑挨个排除

大坑1.make过程遇到  oduleNotFoundError: No module named '_ctypes' 错误

yum install libffi-devel -y
yum install -y openssl*
然后重新configure
重新make然后再make install

大坑2.操作pip3的时候出现ssl错误:pip is configured with locations that require TLS/SSL, however the ssl module in Python is not available.原因是centos6的openssl版本太旧了,需要升级。解决方式如下:

openssl升级过程

1.下载最新的openssl

wget https://www.openssl.org/source/openssl-1.1.1.tar.gz

2.解压gz文件并且编译安装

tar -zvf openssl-1.1.1.tar.gz
cd openssl-1.1.1
./config --prefix=/usr/local/openssl no-zlib #不需要zlib
make && make install

3.软连接到新的openssl

ln -s /usr/local/openssl/include/openssl /usr/include/openssl
ln -s /usr/local/openssl/lib/libssl.so.1.1 /usr/local/lib64/libssl.so
ln -s /usr/local/openssl/bin/openssl /usr/bin/openssl

4.修改系统配置

#写入openssl库文件的搜索路径
echo "/usr/local/openssl/lib" >> /etc/ld.so.conf
#使修改后的/etc/ld.so.conf生效 
ldconfig -v

5.使用openssl version查看版本是否更新正常

更新完openssl后重新安装python3.7即可  

./configure --prefix=/usr/local/python3 --with-openssl=/usr/local/openssl
make
make install

大坑3.目前Django不支持python2.7,换回python2.6又出现了SSL的问题,但是上面的方法并不好使。按如下解决

vi Modules/Setup.dist
//把下面这一段的注释打开,我也不懂是什么意思,但是好使

# Socket module helper for SSL support; you must comment out the other
# socket line above, and possibly edit the SSL variable:
SSL=你自己的openssl的路径
_ssl _ssl.c \
-DUSE_SSL -I$(SSL)/include -I$(SSL)/include/openssl \
-L$(SSL)/lib -lssl -lcrypto

然后保存

保存后重新按正常编译的方式安装就可以了。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值