The problem
This error is common on macOS or OSX when install cryptography with pip:
pip install cryptography
Will return this error:
clang -fno-strict-aliasing -g -O2 -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -I/Users/leonardolazzaro/.pyenv/versions/2.7.11/include/python2.7 -c build/temp.macosx-10.11-
x86_64-2.7/_openssl.c -o build/temp.macosx-10.11-x86_64-2.7/build/temp.macosx-10.11-x86_64-2.7/_openssl.o
build/temp.macosx-10.11-x86_64-2.7/_openssl.c:434:10: fatal error: 'openssl/opensslv.h' file not found
#include <openssl/opensslv.h>
^
1 error generated.
error: command 'clang' failed with exit status 1
Since OSX version equal or bigger then 10.11 (El Capitan), no longer includes OpenSSL headers. After this version you will start to have compilation issues of dependencies that require OpenSSL headers.
With brew you can install a newer version of openssl and also the headers, but pip is still not able to find it. To solve this issue we need to use brew to specify the path where the headers are:
Solution 1
brew install openssl
env LDFLAGS="-L$(brew --prefix openssl)/lib" CFLAGS="-I$(brew --prefix openssl)/include" pip install cryptography
Solution 2
Check with the openssl include path with brew --prefix openssl)/include if it exists, you can try to execute:
cd /usr/local/include
ln -s ../opt/openssl/include/openssl .