Skip to content

Instantly share code, notes, and snippets.

@ceeblet
Created April 9, 2018 16:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ceeblet/77dddf25b610b3dd77c63857d26f9363 to your computer and use it in GitHub Desktop.
Save ceeblet/77dddf25b610b3dd77c63857d26f9363 to your computer and use it in GitHub Desktop.
errors installing cryptography_one solution
brew install openssl
then brew gives a hint:
Apple has deprecated use of OpenSSL in favor of its own TLS and crypto libraries
Generally there are no consequences of this for you. If you build your
own software and it requires this formula, you'll need to add to your
build variables:
LDFLAGS: -L/usr/local/opt/openssl/lib
CPPFLAGS: -I/usr/local/opt/openssl/include
PKG_CONFIG_PATH: /usr/local/opt/openssl/lib/pkgconfig
So just export these env vars and rerun your favorite pip install (or better to avoid havoc in future add following to your ~/.bash_profile:
export LDFLAGS="-L/usr/local/opt/openssl/lib"
export CPPFLAGS="-I/usr/local/opt/openssl/include"
export PKG_CONFIG_PATH="/usr/local/opt/openssl/lib/pkgconfig"
@ceeblet
Copy link
Author

ceeblet commented Apr 9, 2018

another solution was just to upgrade pip
pip install --upgrade pip

@ceeblet
Copy link
Author

ceeblet commented Apr 9, 2018

for reference
pyca/cryptography#2692

@ceeblet
Copy link
Author

ceeblet commented Apr 9, 2018

https://stackoverflow.com/questions/22073516/failed-to-install-python-cryptography-package-with-pip-and-setup-py

Since this SO question keeps coming up I'll drop a response here too (I am one of the pyca/cryptography developers). Here's what you need to reliably install pyca/cryptography on the 3 major platforms.

Please note in all these cases it is highly recommended that you install into a virtualenv and not into the global package space. This is not specific to cryptography but rather is generic advice to keep your Python installation reliable. The global package space in OS provided Pythons is owned by the system and installing things via pip into it is asking for trouble.

Windows

Upgrade to the latest pip (8.1.2 as of June 2016) and just pip install cryptography

cryptography and cffi are both shipped as statically linked wheels.

OS X

Upgrade to the latest pip (8.1.2 as of June 2016) and just pip install cryptography

cryptography and cffi are both shipped as statically linked wheels. This will work for pyenv Python, system Python, homebrew Python, etc. As long as you're on the latest pip you won't even need a compiler.

Linux

As of version 2.0 cryptography ships manylinux1 wheels. This means users with pip 8.1+ running on a glibc-based distribution (almost everything except Alpine Linux) and on x86/x86-64 (sorry Raspberry Pi people) no longer need a compiler or headers because you'll get a precompiled wheel automatically. So, first thing you should try is upgrading your pip!

If you aren't manylinux1 compatible then here's what you need to do:

You'll need a C compiler, libffi + its development headers, and openssl + its development headers.

Debian or Ubuntu derived distributions

apt-get install build-essential libssl-dev libffi-dev python-dev followed by

pip install cryptography

Red Hat derived distributions

yum install gcc openssl-devel libffi-devel python-devel followed by

pip install cryptography

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