简体   繁体   English

Python 2.7 ImportError:没有名为_ssl的模块

[英]Python 2.7 ImportError: no module named _ssl

I'm trying to build python 2.7 in Redhat with SSL. 我正在尝试使用SSL在Redhat中构建python 2.7。 I've uncommented out the lines in Modules/Setup.dist: 我已经取消注释了Modules / Setup.dist中的行:

SSL=/urs/local/ssl
_ssl _ssl.c
-DUSE_SSL -I$(SSL)/include -I$(SSL)/include/openssl
-L$(SSL)/lib -lssl -lcrypto

and I've ensured that OpenSSL is installed on the system, as well as openssl-devel. 我确保在系统上安装OpenSSL,以及openssl-devel。

Prior to installing openssl-devel after running make it would complain that it could not build the module _ssl . 在运行make之后安装openssl-devel之前,它会抱怨它无法构建模块_ssl That error is now gone. 那个错误现在消失了。 Make successfully builds _ssl.o with no errors reported in the log, but does not build lib-dynload/_ssl.so - this is apparently the file that I need to get ssl to work. 成功构建_ssl.o并且日志中没有报告错误,但是没有构建lib-dynload/_ssl.so - 这显然是我需要让ssl工作的文件。 I'm running ./configure with the --enable-shared flag, but so far no matter how I alter the build environment, I can't get that library file to load. 我正在使用--enable-shared标志运行./configure ,但到目前为止,无论我如何改变构建环境,我都无法加载该库文件。

Make successfully builds _ssl.o with no errors reported in the log, but does not build lib-dynload/_ssl.so - this is apparently the file that I need to get ssl to work. 成功构建_ssl.o并且日志中没有报告错误,但是没有构建lib-dynload / _ssl.so - 这显然是我需要让ssl工作的文件。

I don't know about the details of building Python, but on Red Hat you might need to build OpenSSL with: 我不知道构建Python的细节,但是在Red Hat上你可能需要构建OpenSSL:

$ export CFLAGS="-fPIC"
$ ./config shared -no-ssl2 -no-ssl3 --openssldir=/usr/local/ssl ...
...
$ make depend
...
$ make all
...
$ sudo -E make install

After you make install, be sure sure the shared objects are in /usr/local/ssl/lib . 安装完成后,请确保共享对象位于/usr/local/ssl/lib I've encountered the "missing shared objects" on Fedora, and the above fixed the issue for me. 我在Fedora上遇到过“丢失的共享对象”,上面为我解决了这个问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM