10
votes

I am new to mac and I don't understand why my scrapy doesn't seem to work any more. I suspect openssl is not valid in my el capitan.

I tried:

pip install cryptography
pip install pyOpenSSL
brew install openssl

and I still get the error below. Is there some way I can fix this?

$ 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
>>> 
1
What version of pip are you using? Also, what's the output of otool -L /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/cryptography/hazmat/bindings/_openssl.so. It looks like you're installing cryptography into your global Python packages, which is usually an unwise choice, but is not likely to be related to this issue. Edit: Since it's /Library this is likely python.org python. Try uninstalling cryptography and then running env LDFLAGS="-L$(brew --prefix openssl)/lib" CFLAGS="-I$(brew --prefix openssl)/include" pip install cryptography - Paul Kehrer
@PaulKehrer Thanks, apple supplied python and python.org python just got mixed up. After straightening up the lib path it finally worked. - suwopa
Makes sense. The current wheels for pyca/cryptography will work on 10.10+ if you're using the Apple supplied python (or pyenv), but not with python.org. We're working on that limitation. - Paul Kehrer
Have you solved this problem? I have the same problem now. - selfboot

1 Answers

21
votes

I solve this problem by the following command:

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

Refer to if homebrew openssl is linked, cryptography builds an unusable wheel