pip 安装M2Crypto时报错,错误信息如下,找不到openssl相关文件

    copying M2Crypto/SSL/ssl_dispatcher.py -> build/lib.linux-x86_64-2.7/M2Crypto/SSL
    copying M2Crypto/SSL/TwistedProtocolWrapper.py -> build/lib.linux-x86_64-2.7/M2Crypto/SSL
    copying M2Crypto/SSL/Checker.py -> build/lib.linux-x86_64-2.7/M2Crypto/SSL
    copying M2Crypto/SSL/timeout.py -> build/lib.linux-x86_64-2.7/M2Crypto/SSL
    running build_ext
    building 'M2Crypto._m2crypto' extension
    swigging SWIG/_m2crypto.i to SWIG/_m2crypto_wrap.c
    swig -python -D__x86_64__ -I/usr/include/python2.7 -I/usr/include/openssl -I/usr/lib/gcc/x86_64-linux-gnu/7/include -I/usr/local/include -I/usr/lib/gcc/x86_64-linux-gnu/7/include-fixed -I/usr/include/x86_64-linux-gnu -I/usr/include -includeall -modern -builtin -outdir /tmp/pip-install-ndpG9a/M2Crypto/M2Crypto -o SWIG/_m2crypto_wrap.c SWIG/_m2crypto.i
    SWIG/_m2crypto.i:62: Error: Unable to find 'openssl/opensslv.h'
    SWIG/_m2crypto.i:68: Error: Unable to find 'openssl/safestack.h'
    SWIG/_evp.i:12: Error: Unable to find 'openssl/opensslconf.h'
    SWIG/_rc4.i:5: 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

ubuntu18下解决方法:

sudo apt install swig libssl-dev
pip install M2Crypto

mac 下解决方法

brew install openssl
brew install swig
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

注意:linux和mac支持的M2Crypto最新版本不一样

参考:https://stackoverflow.com/questions/33005354/trouble-installing-m2crypto-with-pip-on-os-x-macos

Logo

更多推荐