11

I'm trying to install a python implementation of a proxy re-encryption scheme I found here.

When running $ sudo python setup.py install I get back an error

fatal error: 'openssl/aes.h' file not found

There are a few questions like this around (this or this (not for mac)) but none of the answers there fixed my problem.

I've tried (all taken from answers I found):

  1. Running env LDFLAGS="-L$(brew --prefix openssl)/lib" CFLAGS="-I$(brew --prefix openssl)/include" pip install cryptography and trying again;
  2. brew install openssl and trying again;
  3. brew reinstall python and trying again;

Option 1. returned

Requirement already satisfied: cryptography in /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages
Requirement already satisfied: six>=1.4.1 in /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages (from cryptography)
Requirement already satisfied: setuptools>=11.3 in /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages (from cryptography)
Requirement already satisfied: cffi>=1.4.1 in /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages (from cryptography)
Requirement already satisfied: pyasn1>=0.1.8 in /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages (from cryptography)
Requirement already satisfied: enum34 in /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages (from cryptography)
Requirement already satisfied: ipaddress in /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages (from cryptography)
Requirement already satisfied: idna>=2.0 in /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages (from cryptography)
Requirement already satisfied: pycparser in /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages (from cffi>=1.4.1->cryptography)

I'm running OSX 10.12.6.

Any ideas?

mcansado
  • 2,026
  • 4
  • 25
  • 39
  • 1
    `sudo` drops a lot of the regular user's environment. Things like `env LDFLAGS=...` disappear unless you use options like `-e` and `-E` (IIRC). Build things under an unprivileged account, and use root to install. – jww Aug 16 '17 at 12:09

3 Answers3

24

First check if the path pointed out by $(brew --prefix openssl)/include exists.

If above is fine, you can try

$ cd /usr/local/include
$ ln -s ../opt/openssl/include/openssl .

Look at: Nginx Cannot Find OpenSSL Development Headers

Konrad Rudolph
  • 530,221
  • 131
  • 937
  • 1,214
doptimusprime
  • 9,115
  • 6
  • 52
  • 90
  • Worked for me, when I was hit with a `fatal error: 'openssl/rsa.h' file not found` when installing gRPC for PHP – Aswin Kumar Jun 25 '19 at 06:31
2

Specifying environment variables suggested by Vyper lang docs solved the issue for me:

For MacOS users:

Apple has deprecated use of OpenSSL in favor of its own TLS and crypto libraries. This means that you will need to export some OpenSSL settings yourself, before you can install Vyper.

Use the following commands:

export CFLAGS="-I$(brew --prefix openssl)/include"
export LDFLAGS="-L$(brew --prefix openssl)/lib"
mikheevm
  • 559
  • 5
  • 14
0

Faced this problem with cryptography==1.0.1. Upgraded to 2.9.2.

karuhanga
  • 3,010
  • 1
  • 27
  • 30