首页 新闻 会员 周边

安装python3之后无法引用_ssl

0
[已解决问题] 解决于 2019-01-16 16:40

已安装openssl模块

rpm -qa|grep openssl

openssl-devel-1.0.1e-42.el6_7.4.x86_64
openssl-1.0.1e-42.el6_7.4.x86_64

并通过源码包手动安装了openssl1.1.1版本
OpenSSL 1.1.1-pre3 (beta) 20 Mar 2018 (Library: OpenSSL 1.1.1a 20 Nov 2018)

安装 python的时候修改了源码包里面的
Modules/Setup.dist
Modules/Setup
这2个文件,解除了下面代码的注释,并将SSL路径制定为新版本openssl的安装路径
_socket socketmodule.c
SSL=/usr/local/openssl
_ssl _ssl.c -DUSE_SSL -I$(SSL)/include -I$(SSL)/include/openssl -L$(SSL)/lib -lssl -lcrypto

python安装命令
./configure --prefix=/usr/local/python3 --with-openssl=/usr/local/openssl --with-ssl-default-suites=python
make
make install
在make的时候,有这么一段信息
*** WARNING: renaming "_dbm" since importing it failed: build/lib.linux-x86_64-3.7/_dbm.cpython-37m-x86_64-linux-gnu.so: undefined symbol: dbm_firstkey

Python build finished successfully!
The necessary bits to build these optional modules were not found:
_gdbm
To find the necessary bits, look in setup.py in detect_modules() for the module's name.

The following modules found by detect_modules() in setup.py, have been
built by the Makefile instead, as configured by the Setup files:
_abc _socket _ssl
atexit pwd time

Following modules built successfully but were removed because they could not be imported:
_dbm

python3安装上了,感觉安装是没有问题的,但是在安装模块的时候总提示没有_ssl这个模块

import ssl
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python3.7/ssl.py", line 98, in <module>
import _ssl # if we can't import it, let the error propagate
ModuleNotFoundError: No module named '_ssl'

谁知道这个该怎么处理

一个和🔥有缘的人的主页 一个和🔥有缘的人 | 菜鸟二级 | 园豆:208
提问于:2019-01-16 09:53
< >
分享
最佳答案
0

这个问题归根到底是编译python的时候读取openssl出现了问题,我将/usr/local/目录下的ssl这个文件删掉,然后将我原来安装的openssl1.1.1版本软件,拷贝了一份到/usr/local/目录下并命名为ssl。这样重新编译安装python就可以了。

一个和🔥有缘的人 | 菜鸟二级 |园豆:208 | 2019-01-16 16:40
其他回答(1)
0

为什么要用python ,不用nginx呢?nginx 反向代理过去不是更好吗?然后再使用nginx + ssl

xiaobaiskill | 园豆:1087 (小虾三级) | 2019-01-16 14:38

你理解错误我的场景了,我要用python做web开发的,不是用作代理。
不过这个问题我已经解决了,这个问题归根到底是读取openssl出现了问题,我将/usr/local/目录下的ssl这个文件删掉,然后将我原来安装的openssl1.1.1版本,拷贝了一份到/usr/local/目录下并命名为ssl。这样重新编译安装python就可以了。

支持(0) 反对(0) 一个和🔥有缘的人 | 园豆:208 (菜鸟二级) | 2019-01-16 16:39

@三体: 我知道你用python做web,但是为什么要使用 python + ssl 呢,你这样不就直接占用了443端口了吗?如果还有其他的web?你怎么办呢?所以我说使用nginx 代理,这样你可以有多个web了使用同一个端口了,然后用nginx +ssl ,这样不是更好吗!

支持(0) 反对(0) xiaobaiskill | 园豆:1087 (小虾三级) | 2019-01-16 16:45
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册