New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mac install fails with fatal error: 'openssl/opensslv.h' file not found (tried previous instructions) #3489

Closed
kevinburke opened this Issue Apr 5, 2017 · 11 comments

Comments

Projects
None yet
6 participants
@kevinburke

kevinburke commented Apr 5, 2017

When I run pip install cryptography I get the following error:

... lots of output ...
    running build_ext
    generating cffi module 'build/temp.macosx-10.12-x86_64-2.7/_commoncrypto.c'
    creating build/temp.macosx-10.12-x86_64-2.7
    generating cffi module 'build/temp.macosx-10.12-x86_64-2.7/_padding.c'
    generating cffi module 'build/temp.macosx-10.12-x86_64-2.7/_constant_time.c'
    generating cffi module 'build/temp.macosx-10.12-x86_64-2.7/_openssl.c'
    building '_openssl' extension
    creating build/temp.macosx-10.12-x86_64-2.7/build
    creating build/temp.macosx-10.12-x86_64-2.7/build/temp.macosx-10.12-x86_64-2.7
    cc -arch x86_64 -O2 -fPIC -Wimplicit -I/Users/kevin/src/github.com/jkbrzt/httpie/venv/include -c build/temp.macosx-10.12-x86_64-2.7/_openssl.c -o build/temp.macosx-10.12-x86_64-2.7/build/temp.macosx-10.12-x86_64-2.7/_openssl.o
    build/temp.macosx-10.12-x86_64-2.7/_openssl.c:433:10: fatal error: 'openssl/opensslv.h' file not found
    #include <openssl/opensslv.h>

Issue #3367 suggested upgrading pip. I am using the latest version of pip:

$ pip install -U pip
Requirement already up-to-date: pip in ./venv/site-packages
$ pip --version
pip 9.0.1 from /Users/kevin/src/github.com/jkbrzt/httpie/venv/site-packages (python 2.7)

It also fails outside of the virtualenv. I am not sure why pip is trying to build the wheel instead of using the downloadable wheel.

I tried removing ~/Library/Caches/pip and reinstalling and I am getting the same error.

I use Homebrew but brew link openssl --force fails now with this error message:

$ brew link openssl
Warning: Refusing to link: openssl
Linking keg-only openssl means you may end up linking against the insecure,
deprecated system OpenSSL while using the headers from Homebrew's openssl.
Instead, pass the full include/library paths to your compiler e.g.:
  -I/usr/local/opt/openssl/include -L/usr/local/opt/openssl/lib

I tried running LDFLAGS="-I/usr/local/opt/openssl/include -L/usr/local/opt/openssl/lib" pip install cryptography and got the same error as above. I also tried pip install cryptography --global-option="-L/usr/local/opt/openssl/lib" and got a different, but not more promising, error.

Here is the Python version both inside and outside of the virtual environment:

$ python
Python 2.7.12 (aff251e54385, Nov 09 2016, 17:25:49)
[PyPy 5.6.0 with GCC 4.2.1 Compatible Apple LLVM 5.1 (clang-503.0.40)] on darwin
Type "help", "copyright", "credits" or "license" for more information.

Here is the system openssl:

$ openssl version
OpenSSL 0.9.8zh 14 Jan 2016

Here is the Homebrew openssl version (not sure how to link this or specify it when running pip install)

$ /usr/local/Cellar/openssl/1.0.2k/bin/openssl version
OpenSSL 1.0.2k  26 Jan 2017

I am running macOS Sierra version 10.12.4. Happy to provide any more debugging information as necessary; I'm not sure what more you would look for.

@kevinburke kevinburke changed the title from Mac install fails with fatal error: 'openssl/opensslv.h' file not found to Mac install fails with fatal error: 'openssl/opensslv.h' file not found (tried previous instructions) Apr 5, 2017

@kevinburke

This comment has been minimized.

Show comment
Hide comment
@kevinburke

kevinburke Apr 5, 2017

Huh, this incantation worked (I left off the --global-option=build_ext before):

pip install cryptography --global-option=build_ext --global-option="-L/usr/local/opt/openssl/lib" --global-option="-I/usr/local/opt/openssl/include"

kevinburke commented Apr 5, 2017

Huh, this incantation worked (I left off the --global-option=build_ext before):

pip install cryptography --global-option=build_ext --global-option="-L/usr/local/opt/openssl/lib" --global-option="-I/usr/local/opt/openssl/include"
@reaperhulk

This comment has been minimized.

Show comment
Hide comment
@reaperhulk

reaperhulk Apr 5, 2017

Member

Huh, we definitely ship wheels for that Python/macOS version (in fact most of us develop on that!). Could you give me the output of: python -c "import pprint;from pip import pep425tags;pp = pprint.PrettyPrinter(indent=4);pp.pprint(pep425tags.get_supported())" ?

Member

reaperhulk commented Apr 5, 2017

Huh, we definitely ship wheels for that Python/macOS version (in fact most of us develop on that!). Could you give me the output of: python -c "import pprint;from pip import pep425tags;pp = pprint.PrettyPrinter(indent=4);pp.pprint(pep425tags.get_supported())" ?

@kevinburke

This comment has been minimized.

Show comment
Hide comment
@reaperhulk

This comment has been minimized.

Show comment
Hide comment
@reaperhulk

reaperhulk Apr 5, 2017

Member

Ah, you're actually running on pypy? pypy's ABI stability for wheels has historically been problematic so we haven't been shipping wheels there. For example, your gist shows the ABI tag for your version would be pp256-pypy_41. This probably means it's pypy2 5.6? I have a copy of pypy2 5.4 on my machine and the wheel tag is pp254-pypy_41. So we'd need to have different wheels for every version 😢

Maybe we need to do a better job documenting what to do if you're on the latest pip and still get this error (or prominently note that pypy, while supported, does not have prebuilt wheels unfortunately)

Member

reaperhulk commented Apr 5, 2017

Ah, you're actually running on pypy? pypy's ABI stability for wheels has historically been problematic so we haven't been shipping wheels there. For example, your gist shows the ABI tag for your version would be pp256-pypy_41. This probably means it's pypy2 5.6? I have a copy of pypy2 5.4 on my machine and the wheel tag is pp254-pypy_41. So we'd need to have different wheels for every version 😢

Maybe we need to do a better job documenting what to do if you're on the latest pip and still get this error (or prominently note that pypy, while supported, does not have prebuilt wheels unfortunately)

@kevinburke

This comment has been minimized.

Show comment
Hide comment
@kevinburke

kevinburke Apr 5, 2017

Oh, right.

Ideally in the error message from pip install - is that even possible? or easily searchable - for example in the comments to #3367 which was the first Google result I landed on.

kevinburke commented Apr 5, 2017

Oh, right.

Ideally in the error message from pip install - is that even possible? or easily searchable - for example in the comments to #3367 which was the first Google result I landed on.

@alex

This comment has been minimized.

Show comment
Hide comment
@alex

alex Apr 5, 2017

Member

Seems like an actionable item here is to improve our FAQ question answer to mention PyPy.

Member

alex commented Apr 5, 2017

Seems like an actionable item here is to improve our FAQ question answer to mention PyPy.

alex added a commit to alex/cryptography that referenced this issue Apr 8, 2017

@reaperhulk reaperhulk closed this in e660ffe Apr 9, 2017

@kevinburke

This comment has been minimized.

Show comment
Hide comment
@kevinburke

kevinburke Apr 9, 2017

kevinburke commented Apr 9, 2017

@heralight

This comment has been minimized.

Show comment
Hide comment
@heralight

heralight May 14, 2017

Ok, fixed.
There was some old dependencies in Pillow which force downgrade to cryptography 1.5.1 which have this bug.
Force dependency to cryptography==1.8.1 do the trick.

best regards,

Alexandre

Hi,

I have exact same problem without pypy on fresh virtualenv set with python 3.6 on mac sierra .
https://gist.github.com/heralight/bdbcd2edd4248acf50c330fc59713653

#3489 (comment)
this comment fix this issue but this solution is not very handy...
do you have an idea howto fix this problem ?

Thank guy !

heralight commented May 14, 2017

Ok, fixed.
There was some old dependencies in Pillow which force downgrade to cryptography 1.5.1 which have this bug.
Force dependency to cryptography==1.8.1 do the trick.

best regards,

Alexandre

Hi,

I have exact same problem without pypy on fresh virtualenv set with python 3.6 on mac sierra .
https://gist.github.com/heralight/bdbcd2edd4248acf50c330fc59713653

#3489 (comment)
this comment fix this issue but this solution is not very handy...
do you have an idea howto fix this problem ?

Thank guy !

@rgardam

This comment has been minimized.

Show comment
Hide comment
@rgardam

rgardam Jul 3, 2017

I was able to get this to work by upgrading openssl using brew

brew upgrade openssl

and then setting the CPPFLAGS and LDFLAGS to point to the openssl lib from brew

export CPPFLAGS=-I/usr/local/opt/openssl/include
export LDFLAGS=-L/usr/local/opt/openssl/lib

rgardam commented Jul 3, 2017

I was able to get this to work by upgrading openssl using brew

brew upgrade openssl

and then setting the CPPFLAGS and LDFLAGS to point to the openssl lib from brew

export CPPFLAGS=-I/usr/local/opt/openssl/include
export LDFLAGS=-L/usr/local/opt/openssl/lib
@philipplaeubli

This comment has been minimized.

Show comment
Hide comment
@philipplaeubli

philipplaeubli Jul 26, 2017

Thanks @rgardam!
Actually just setting the CPPFLAGS and LDFLAGS was enough in my environment.

philipplaeubli commented Jul 26, 2017

Thanks @rgardam!
Actually just setting the CPPFLAGS and LDFLAGS was enough in my environment.

@pyca pyca locked and limited conversation to collaborators Jul 26, 2017

@reaperhulk

This comment has been minimized.

Show comment
Hide comment
@reaperhulk

reaperhulk Jul 26, 2017

Member

Since this issue keeps coming up I'm going to lock this conversation, but for reference:

Member

reaperhulk commented Jul 26, 2017

Since this issue keeps coming up I'm going to lock this conversation, but for reference:

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.