python3.7.3升级 with-openssl openssl-1.0.2a

zhouhaihua00 2019-12-29

## 系统环境
- Red Hat Enterprise Linux Server release 6.8 (Santiago)
- Python2.6.6
- openssl version 1.0.1

## 一、安装gcc
yum -y install gcc gcc-c++

## 二、安装python3.7.3
1. 首先对相关的软件进行更新
```shell
python -V
yum -y update
#yum groupinstall -y development
yum install -y zlib zlib-dev openssl openssl-devel sqlite sqlite-devel bzip bzip2-devel mysql-devel python-devel readline-devel libffi-devel
yum install -y
```
2. 安装更新openssl
```shell
tar -zxvf openssl-1.0.2a.tar.gz
cd openssl-1.0.2a
./config --prefix=/user/local/openssl-1.0.2a shared zlib
make && make install
echo "export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/user/local/openssl-1.0.2a/lib" >> ~/.bash_profile
echo "export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/user/local/openssl-1.0.2a/lib" >> /etc/profile
source /etc/profile
```
验证方式
```python
>>> import ssl
>>> import _ssl
```

3. 安装更新Python,并修改相关的配置信息
```shell
cd Python3.7.3
./configure --with-ssl-default-suites=python --with-openssl=/usr/local/openssl-1.0.2a prefix=/usr/local/python3 --enable-optimizations
make && make install

mv /usr/bin/python /usr/bin/python2.6.6
ln -s /usr/local/bin/python3.7 /usr/bin/python
ln -s /usr/local/python3/bin/pip3 /usr/bin/pip
```

3.将yum的配置连接依依旧还是指向Python2.6

(yum依赖的是Python2.6,所以在更新之后不能够使用)
```shell
vi /usr/bin/yum
# 第一行改为: #!/usr/bin/python2.6
```

## 三、安装python依赖(顺序)
```
numpy-1.16.0
nose-1.3.7
pytz-2019.1
python-dateutil-2.8.0
six-1.10.0
pandas-0.24.2
configparser-3.7.4
MySQL-python-1.2.5
```

## 问题

+ 安装ssl时提示 zlib.h 找不到
- 重新编译安装 zlib-1.2.11.tar.gz
- ./configure && make && make install
+ MySQL-python-1.2.5提示ConfigParser包不存在: no module name ‘ConfigParser‘
- 已安装安装了configparser-3.7.4, 还是会报错
- 解决办法: 修改那个提示的py文件: MySQL-python-1.2.5/setup_posix.py, 将`from ConfigParser import SafeConfiParser` 改为小写 `import configparser import SafeConfiParser`

相关推荐