【问题标题】:Can not import M2Crypro for Mac OS X 10.10.5无法为 Mac OS X 10.10.5 导入 M2Crypto
【发布时间】:2015-12-07 09:43:27
【问题描述】:

我试图安装 M2Crypto 但sudo pip install M2Crypto 出现以下错误:

850 warnings and 3 errors generated.
    error: command 'cc' failed with exit status 1

    ----------------------------------------
  Rolling back uninstall of M2Crypto
Command "/usr/bin/python -c "import setuptools, tokenize;__file__='/private/tmp/pip-build-uSFYDz/M2Crypto/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-Nsz5C6-record/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /private/tmp/pip-build-uSFYDz/M2Crypto

然后我安装了sudo pip install M2Crypto==0.21.1。它没有给出任何错误,但是当我尝试导入以下错误时:

>>> import M2Crypto
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Library/Python/2.7/site-packages/M2Crypto/__init__.py", line 24, in <module>
    import ASN1
  File "/Library/Python/2.7/site-packages/M2Crypto/ASN1.py", line 12, in <module>
    import BIO
  File "/Library/Python/2.7/site-packages/M2Crypto/BIO.py", line 221, in <module>
    class CipherStream(BIO):
  File "/Library/Python/2.7/site-packages/M2Crypto/BIO.py", line 227, in CipherStream
    SALT_LEN = m2.PKCS5_SALT_LEN
AttributeError: 'module' object has no attribute 'PKCS5_SALT_LEN'

任何帮助表示赞赏!

【问题讨论】:

    标签: macos python-2.7 m2crypto


    【解决方案1】:

    INSTALL 在 Mac 上安装时说:

    Apple 不提供更新版本的 Mac OS X(至少 当然自 10.11 以来)任何版本的 OpenSSL,因此有必要 使用 brew 或类似的包装系统安装第三方 包。一位 Mac OS X 用户建议,这一系列命令 在他的系统上给了他一份 M2Crypto 的工作副本: $ brew install openssl && brew install swig $ brew --prefix openssl /usr/local/opt/openssl $ LDFLAGS="-L$(brew --prefix openssl)/lib" CFLAGS="-I$(brew --prefix openssl)/include" \ SWIG_FEATURES="-I$(brew --prefix openssl)/include" \ pip install m2crypto

    恐怕完全自动化的pip安装是行不通的 自动取款机。任何查找 OpenSSL 现有安装的合并请求,其中 将在 Mac 上进行测试,谢天谢地。

    【讨论】:

    • @david-fang 你能接受我的回答吗?谢谢。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2015-12-07
    • 2016-07-03
    • 2015-11-28
    • 2011-06-15
    • 2016-02-12
    • 2016-05-19
    • 1970-01-01
    相关资源
    最近更新 更多