centos6.9安装python3.6.9独立的virtualenv环境,并且能正确引入ssl

centos6.9安装python3.6.9独立的virtualenv环境,并且能正确引入ssl

1.编译安装python3.6环境
# 安装依赖
yum -y install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gdbm-devel db4-devel libpcap-devel xz-devel
# 获取编译安装python3.6.6
mkdir -p /usr/local/python36

cd /usr/local/src
wget https://www.python.org/ftp/python/3.6.9/Python-3.6.9.tgz
tar xf Python-3.6.9.tgz
cd Python-3.6.9

# 修改如下205,209~212 共5行,去掉前面的# 号注释
vim Modules/Setup.dist

205 _socket socketmodule.c
206
207 # Socket module helper for SSL support; you must comment out the other
208 # socket line above, and possibly edit the SSL variable:
209 SSL=/usr/local/ssl
210 _ssl _ssl.c \
211         -DUSE_SSL -I$(SSL)/include -I$(SSL)/include/openssl \
212         -L$(SSL)/lib -lssl -lcrypto


./configure --prefix=/usr/local/python36
make && make install

# 验证ssl是否能够正常引入
# /usr/local/python36/bin/python3
Python 3.6.9 (default, Dec 19 2019, 00:56:46)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-18)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import ssl


ln -s /usr/local/python36/bin/python3 /usr/bin/python3
ln -s /usr/local/python36/bin/pip3 /usr/bin/pip3

2.安装virtualenv虚拟环境
pip3 install virtualenv
# 创建存放虚拟环境的目录
mkdir -p /usr/local/monitor_api_venv

# 创建纯净的虚拟环境
# /usr/local/python36/bin/virtualenv --no-site-packages --python=/usr/local/python36/bin/python3.6 /usr/local/monitor_api_venv

 

后面报错 virtualenv: error: unrecognized arguments: --no-site-packages

可以直接通过 /usr/local/python36/bin/virtualenv --python=/usr/local/python36/bin/python3.6 /usr/local/monitor_api_venv 创建虚拟环境

 

在centos10中安装python3.6.8以后发现php报错,解决思路如下

报错
[root@newcms:~]# php -v
php: /lib64/libc.so.6: version `GLIBC_2.14' not found (required by /usr/lib64/libxml2.so.2)
php: /lib64/libc.so.6: version `GLIBC_2.15' not found (required by /usr/lib64/libxml2.so.2)
php: /lib64/libc.so.6: version `GLIBC_2.14' not found (required by /usr/lib64/liblzma.so.5)
php: /lib64/libc.so.6: version `GLIBC_2.17' not found (required by /usr/lib64/liblzma.so.5)

查看正常centos6.10的指向
[root@sz_xx_cmsby01_11_99:~]# ll /usr/lib64/libxml2.so.2
lrwxrwxrwx. 1 root root 16 Jul  2  2018 /usr/lib64/libxml2.so.2 -> libxml2.so.2.7.6

查看了一下文件的指向,发现指向了高版本
[root@newcms:/usr/lib64]# ll /usr/lib64/libxml2.so.2
lrwxrwxrwx 1 root root 16 Nov 11 11:30 /usr/lib64/libxml2.so.2 -> libxml2.so.2.9.1

解决办法,重新指向老版本
rm -f /usr/lib64/libxml2.so.2
ln -s  /usr/lib64/libxml2.so.2.7.6 /usr/lib64/libxml2.so.2

 

posted @ 2019-12-19 17:03  reblue520  阅读(319)  评论(0编辑  收藏  举报