Cryptography: Installation Fails on Mac OS X 10.11 Beta 6 and GM

Created on 17 Sep 2015  Â·  20Comments  Â·  Source: pyca/cryptography

Python Version: 3.5.0
OS Version: Mac OS X 10.11 Beta 6 and GM tested.

Running setup.py install for cryptography
    Complete output from command /Users/coltonprovias/Development/MyNewLeaf/bin/python3.5 -c "import setuptools, tokenize;__file__='/private/var/folders/zl/0vgdj8l96ss0_w20j9k0t7bm0000gn/T/pip-build-b7m8lm64/cryptography/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /var/folders/zl/0vgdj8l96ss0_w20j9k0t7bm0000gn/T/pip-he90mckx-record/install-record.txt --single-version-externally-managed --compile --install-headers /Users/coltonprovias/Development/MyNewLeaf/bin/../include/site/python3.5/cryptography:
    running install
    running build
    running build_py
    running egg_info
    writing entry points to src/cryptography.egg-info/entry_points.txt
    writing top-level names to src/cryptography.egg-info/top_level.txt
    writing dependency_links to src/cryptography.egg-info/dependency_links.txt
    writing src/cryptography.egg-info/PKG-INFO
    writing requirements to src/cryptography.egg-info/requires.txt
    warning: manifest_maker: standard file '-c' not found

    reading manifest file 'src/cryptography.egg-info/SOURCES.txt'
    reading manifest template 'MANIFEST.in'
    no previously-included directories found matching 'docs/_build'
    warning: no previously-included files matching '*' found under directory 'vectors'
    writing manifest file 'src/cryptography.egg-info/SOURCES.txt'
    running build_ext
    generating cffi module 'build/temp.macosx-10.11-x86_64-3.5/_commoncrypto.c'
    already up-to-date
    generating cffi module 'build/temp.macosx-10.11-x86_64-3.5/_padding.c'
    already up-to-date
    generating cffi module 'build/temp.macosx-10.11-x86_64-3.5/_constant_time.c'
    already up-to-date
    generating cffi module 'build/temp.macosx-10.11-x86_64-3.5/_openssl.c'
    already up-to-date
    building '_openssl' extension
    clang -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -I/usr/local/Cellar/python3/3.5.0/Frameworks/Python.framework/Versions/3.5/include/python3.5m -c build/temp.macosx-10.11-x86_64-3.5/_openssl.c -o build/temp.macosx-10.11-x86_64-3.5/build/temp.macosx-10.11-x86_64-3.5/_openssl.o
    build/temp.macosx-10.11-x86_64-3.5/_openssl.c:400:10: fatal error: 'openssl/aes.h' file not found
    #include <openssl/aes.h>
             ^
    1 error generated.
    error: command 'clang' failed with exit status 1

This is due to Apple dropping support for OpenSSL and moving to their own library.

Workaround for those encountering issue:

Install OpenSSL via Homebrew and then run the following command:

env LDFLAGS="-L$(brew --prefix openssl)/lib" CFLAGS="-I$(brew --prefix openssl)/include" pip install cryptography

No other issues encountered yet.

Most helpful comment

the OP solution worked for me, thanks!
env LDFLAGS="-L$(brew --prefix openssl)/lib" CFLAGS="-I$(brew --prefix openssl)/include" pip install cryptography

All 20 comments

Yeah, we're aware of the change. Apple's removal of the El Capitan OpenSSL headers is (part of) why we chose to start shipping binary wheels for 10.10+. Our wheels are relatively conservative at the moment though so system Python (as well as Python 3.5) does not receive the wheels. We've documented the required dependencies (OpenSSL from homebrew or macports) here, although it lacks the nuance described above.

We'll be shipping universal (32-bit/64-bit) wheels in the next release along with Python 3.5 wheels to simplify this.

Thanks for the report!

For anyone viewing this because installing a package which installs cryptography with Homebrew fails, you can add the following to your recipe:

depends_on "openssl" and

ENV["LDFLAGS"] = "-L#{opt_prefix}/openssl/lib"
ENV["CFLAGS"] = "-I#{opt_prefix}/openssl/include"

I have encountered this and the command provided in the first comment solve the issue. Running on python 2.7

I had the same problem and resolved it by upgrading globally installed virtualenv, setuptools and pip

the OP solution worked for me, thanks!
env LDFLAGS="-L$(brew --prefix openssl)/lib" CFLAGS="-I$(brew --prefix openssl)/include" pip install cryptography

Anyone still experiencing this issue should upgrade their pip, as it's highly likely that their installation is out of date. An up to date pip will download a binary wheel of cffi and cryptography and will not require any compilation :)

the issue remains with pypy, this solution (proposed above) worked well for me:
sudo -H env LDFLAGS="-L$(brew --prefix openssl)/lib" CFLAGS="-I$(brew --prefix openssl)/include" pypy -m pip install -U cryptography

env LDFLAGS="-L$(brew --prefix openssl)/lib" CFLAGS="-I$(brew --prefix openssl)/include" pip install cryptography - After an hour trying different solutions this was the one that fixed it for me.

Above solution does not work for me.
build/temp.macosx-10.11-x86_64-2.7/_openssl.c:431:10: fatal error:
'openssl/aes.h' file not found

include

I tried running env LDFLAGS="-L$(brew --prefix openssl)/lib" CFLAGS="-I$(brew --prefix openssl)/include" pip install cryptography in my user root and also inside my virtualenv environement, the running ./env/bin/python setup.py install inside my env folder. Still doesnt work. Perhaps the solution is no longer viable on 10.11? Any ideas? Thank you.

Your best bet is to upgrade to the latest version of pip; then you'll get cryptography distributed as a wheel.

I upgraded previously to pip -V
pip 8.1.0 from /usr/local/lib/python2.7/site-packages (python 2.7)

Should i go back to 8.03?

pip 8.1.0 is fine

On Sun, Mar 6, 2016 at 9:29 AM, Alain Armand [email protected]
wrote:

I upgraded previously to pip -V
pip 8.1.0 from /usr/local/lib/python2.7/site-packages (python 2.7)

Should i go back to 8.03?

—
Reply to this email directly or view it on GitHub
https://github.com/pyca/cryptography/issues/2350#issuecomment-192896674.

"I disapprove of what you say, but I will defend to the death your right to
say it." -- Evelyn Beatrice Hall (summarizing Voltaire)
"The people's good is the highest law." -- Cicero
GPG Key fingerprint: 125F 5C67 DFE9 4084

Any other ideas?

OP solution worked for me...

it works ! On python 2.7,el captain 10.11.2.

For posterity, I had to use virtualenv-burrito upgrade to upgrade pip because (you guessed it) I'm using the excellent virtualenv-burrito.
Without doing this I got the following error:

Not uninstalling pip at /Users/dave/.venvburrito/lib/python2.7/site-packages/pip-7.1.2-py2.7.egg, outside environment /Users/dave/.virtualenvs/ansible2++/bin/..

WOW! Many thanks! This just fixed my problem!

I manage to solve it following this instructions

env LDFLAGS="-L$(brew --prefix openssl)/lib" CFLAGS="-I$(brew --prefix openssl)/include" pip install cryptography does not work for me.

But this works for me.

My PC is macOS High Sierra.

@hidehiro98 your solution also works for me. Thanks!
Mine is macOS High Sierra as well.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

webknjaz picture webknjaz  Â·  5Comments

wexi picture wexi  Â·  5Comments

webknjaz picture webknjaz  Â·  7Comments

DurandA picture DurandA  Â·  5Comments

kamikaze picture kamikaze  Â·  7Comments