【问题标题】:Symbol not found: _BIO_new_CMS未找到符号:_BIO_new_CMS
【发布时间】:2016-02-01 11:03:01
【问题描述】:

我是 mac 新手,我不明白为什么我的 scrapy 似乎不再工作了。我怀疑 openssl 在我的 el capitan 中无效。

我试过了:

pip install cryptography
pip install pyOpenSSL
brew install openssl

我仍然收到以下错误。 有什么办法可以解决这个问题吗?

$ python
Python 2.7.10 (v2.7.10:15c95b7d81dc, May 23 2015, 09:33:12) 
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import OpenSSL
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/OpenSSL/__init__.py", line 8, in <module>
    from OpenSSL import rand, crypto, SSL
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/OpenSSL/rand.py", line 11, in <module>
    from OpenSSL._util import (
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/OpenSSL/_util.py", line 3, in <module>
    from cryptography.hazmat.bindings.openssl.binding import Binding
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/cryptography/hazmat/bindings/openssl/binding.py", line 13, in <module>
    from cryptography.hazmat.bindings._openssl import ffi, lib
ImportError: dlopen(/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/cryptography/hazmat/bindings/_openssl.so, 2): Symbol not found: _BIO_new_CMS
  Referenced from: /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/cryptography/hazmat/bindings/_openssl.so
  Expected in: flat namespace
 in /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/cryptography/hazmat/bindings/_openssl.so
>>> 

【问题讨论】:

  • 您使用的是什么版本的 pip?另外,otool -L /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/cryptography/hazmat/bindings/_openssl.so 的输出是什么。看起来您正在将密码学安装到全局 Python 包中,这通常是一个不明智的选择,但不太可能与此问题相关。编辑:因为它是 /Library 这很可能是 python.org python。尝试卸载加密然后运行env LDFLAGS="-L$(brew --prefix openssl)/lib" CFLAGS="-I$(brew --prefix openssl)/include" pip install cryptography
  • @PaulKehrer 谢谢,苹果提供的 python 和 python.org python 刚刚混淆了。在理顺了 lib 路径后,它终于起作用了。
  • 有道理。如果您使用的是 Apple 提供的 python(或 pyenv),那么当前用于 pyca/cryptography 的轮子将在 10.10+ 上运行,但不适用于 python.org。我们正在努力解决这个限制。
  • 这个问题你解决了吗?我现在也有同样的问题。

标签: python macos python-2.7 scrapy osx-elcapitan


【解决方案1】:

我通过以下命令解决了这个问题:

LDFLAGS="-L/usr/local/opt/openssl/lib" pip install cryptography --no-use-wheel

参考if homebrew openssl is linked, cryptography builds an unusable wheel

【讨论】:

  • 在 pip 命令之前添加这个 LDFLAGS 位帮助我在 OSX 上安装了 scrapy
  • hhh 我也是@saturdayplace
  • 值得注意的是,这个命令应该在pip uninstall cryptography之后运行,以摆脱之前安装的版本。
  • 除非我无法摆脱以前的版本,因为pip uninstall cryptography 给了我这个错误并中断。
  • 以防万一,也检查一下:apple.stackexchange.com/questions/209572/… --它为我解决了类似的pip 问题。 YMMV。
猜你喜欢
  • 1970-01-01
  • 2012-04-26
  • 2021-12-17
  • 2021-07-18
  • 2014-08-31
  • 2018-10-21
  • 2021-01-06
  • 2012-12-28
  • 1970-01-01
相关资源
最近更新 更多