无法在OS X/macOS上使用pip安装m2crypto [英] Trouble installing m2crypto with pip on OS X / macOS

查看:373
本文介绍了无法在OS X/macOS上使用pip安装m2crypto的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

pip install m2crypto

生成以下输出:

building 'M2Crypto.__m2crypto' extension
swigging SWIG/_m2crypto.i to SWIG/_m2crypto_wrap.c
swig -python -I/System/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7 -I/usr/include -I/usr/include/openssl -includeall -modern -o SWIG/_m2crypto_wrap.c SWIG/_m2crypto.i
SWIG/_m2crypto.i:30: Error: Unable to find 'openssl/opensslv.h'
SWIG/_m2crypto.i:33: Error: Unable to find 'openssl/safestack.h'
SWIG/_evp.i:12: Error: Unable to find 'openssl/opensslconf.h'
SWIG/_ec.i:7: Error: Unable to find 'openssl/opensslconf.h'
error: command 'swig' failed with exit status 1

我已经跑步:

brew install swig

推荐答案

我想要一种更好的方法,而无需手动安装并且仅使用Homebrew(默认情况下也不会链接openssl).还必须使用pip.这似乎适用于最新的m2crypto 0.22.5.我还使用m2crypto 0.22.3对其进行了测试,并且似乎也可以正常工作.这里的OpenSSL版本是1.0.2d:

I wanted a nicer way without installing manually and using only Homebrew (which also does not link openssl by default). Also using pip was a requirement. This seems to work with newest m2crypto 0.22.5. I also tested it once with m2crypto 0.22.3 and seems also to work. The OpenSSL version here is 1.0.2d:

brew install openssl
brew install swig

最后在 Bash 中的macOS上安装m2crypto.这是一个很长的命令,但是它仅在pip install期间更改SWIG和clang环境变量,以便m2crypto将获得所有OpenSSL要求:

Finally install m2crypto on macOS in your Bash. It is a long command but it changes SWIG and clang environment variables only during pip install so that m2crypto will get all OpenSSL requirements:

env LDFLAGS="-L$(brew --prefix openssl)/lib" \
CFLAGS="-I$(brew --prefix openssl)/include" \
SWIG_FEATURES="-cpperraswarn -includeall -I$(brew --prefix openssl)/include" \
pip install m2crypto

顺便说一句.如果您使用例如,最后一个命令也可以使用一个requirements.txt.

btw. the last command also works if you use e.g. a requirements.txt.

更新:
另外还有鱼壳用户的命令...

Update:
Additional also the command for fish shell users...

env LDFLAGS="-L"(brew --prefix openssl)"/lib" \
CFLAGS="-I"(brew --prefix openssl)"/include" \
SWIG_FEATURES="-cpperraswarn -includeall -I"(brew --prefix openssl)"/include" \
pip install m2crypto

这篇关于无法在OS X/macOS上使用pip安装m2crypto的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆