在MacOS上从源代码构建python时,我偶然改写了MacOS随附的python,现在它没有SSL.我试图通过运行–with-ssl选项来重新构建
<code>./configure --with-ssl </code>
但是当我随后运行make时,它说的是
<code>Python build finished, but the necessary bits to build these modules were not found: _bsddb _ssl dl imageop linuxaudiodev ossaudiodev readline spwd sunaudiodev To find the necessary bits, look in setup.py in detect_modules() for the module's name. </code>
从setup.py看不清楚,我应该怎么做才能找到“必需的位”.如何在MacOS上使用SSL构建python?
解决方法:
只需打开setup.py并找到方法detect_modules().它有一些类似(对我来说是2.7.11)的行:
<code> # Detect SSL support for the socket module (via _ssl)
search_for_ssl_incs_in = [
'/usr/local/ssl/include',
'/usr/contrib/ssl/include/'
]
ssl_incs = find_file('openssl/ssl.h', inc_dirs,
search_for_ssl_incs_in
)
if ssl_incs is not None:
krb5_h = find_file('krb5.h', inc_dirs,
['/usr/kerberos/include'])
if krb5_h:
ssl_incs += krb5_h
ssl_libs = find_library_file(self.compiler, 'ssl',lib_dirs,
['/usr/local/ssl/lib',
'/usr/contrib/ssl/lib/'
] )
if (ssl_incs is not None and
ssl_libs is not None):
exts.append( Extension('_ssl', ['_ssl.c'],
include_dirs = ssl_incs,
library_dirs = ssl_libs,
libraries = ['ssl', 'crypto'],
depends = ['socketmodule.h']), )
else:
missing.append('_ssl')
</code>
因此,似乎您需要SSL和Kerberos. Kerberos随Mac一起安装.因此,您需要安装openssl.您可以用brew做它:
<code>brew install openssl </code>
openssl标头可以安装在与Python搜索不同的路径中.所以发出
<code>locate ssl.h </code>
并将路径添加到search_for_ssl_incs_in.例如对于我来说是:
<code>/usr/local/Cellar/openssl/1.0.2d_1/include/openssl/ssl.h </code>
因此,我应该将/usr/local/Cellar/openssl/1.0.2d_1/include/添加到search_for_ssl_incs_in中.
不要忘记这些是针对python 2.7.11的.但是过程应该相同.
希望能有所帮助.
【说明】:本文章由站长整理发布,文章内容不代表本站观点,如文中有侵权行为,请与本站客服联系(QQ:254677821)!