3 回答

TA贡献1735条经验 获得超5个赞
如果Modules/Setup.distOpenSSL不在标准位置,则需要进行编辑以指定其位置。从在Python 2.5.1中获得SSL支持:
如果您发现自己的Linux框需要python的ssl支持(以在诸如httplib.HTTPSConnection或imaplib.IMAP4_SSL之类的客户端中使用客户端),那么让我为您节省几个小时的网上搜索(当然,如果您有找到这个,则意味着您已经完成了一些关卡搜寻!)。
如果收到以下异常消息,您将知道是否需要将ssl支持编译到python安装中:AttributeError:'module'对象没有属性'ssl'
为了使它消失,以便您可以继续愉快地悬吊python代码,首先需要确保已安装OpenSSL。默认情况下,它是从/ usr / local / ssl的源代码安装的
如果该目录不存在,请获取源包。
执行标准:
tar zxf openssl-0.9.8g.tar.gz
cd openssl-0.9.8g
./config
make
make install
然后获取2.5.1和以下版本的python源:tar zxf Python-2.5.1.tgz && cd Python-2.5.1
然后,您需要编辑Modules / Setup.dist:
204:# Socket module helper for SSL support; you must comment out the other
205:# socket line above, and possibly edit the SSL variable:
206:SSL=/usr/local/ssl
207:_ssl _ssl.c \
208: -DUSE_SSL -I$(SSL)/include -I$(SSL)/include/openssl \
209: -L$(SSL)/lib -lssl -lcrypto
如果您在默认位置安装了OpenSSL,则只需取消注释行206-209,即可:
./configure
make
make install
然后使用以下命令验证您的安装:
python /usr/local/lib/python2.5/test/test_socket_ssl.py
test_rude_shutdown ...
test_basic ...
test_timeout ...
Modules/Setup.dist通过清除源根目录(例如make distclean)configure并make再次运行来确保获取更改。

TA贡献1887条经验 获得超5个赞
在Bourne Shell(/ bin / sh或/ bin / bash)中:
$ LD_LIBRARY_PATH=/usr/local/lib
$ export LD_LIBRARY_PATH
$ make
在C-shell(/ bin / csh或/ bin / tcsh)中:
% setenv LD_LIBRARY_PATH /usr/local/lib
% make
添加回答
举报