Installing Cryptography via Pip with MacPorts or Homebrew

If you have tried installing / updating pyOpenSSL to version 0.14 you may have run into an issue when it tries to install the required package cryptography. The specific error I encountered was:

raise ffiplatform.VerificationError(error)
cffi.ffiplatform.VerificationError: importing '/private/tmp/pip_build_root/cryptography/cryptography/hazmat/bindings/__pycache__/_cffi__x5eaa210axf0ae7e21.so': dlopen(/private/tmp/pip_build_root/cryptography/cryptography/hazmat/bindings/__pycache__/_cffi__x5eaa210axf0ae7e21.so, 2): Symbol not found: _CRYPTO_malloc_debug_init
Referenced from: /private/tmp/pip_build_root/cryptography/cryptography/hazmat/bindings/__pycache__/_cffi__x5eaa210axf0ae7e21.so
Expected in: flat namespace
in /private/tmp/pip_build_root/cryptography/cryptography/hazmat/bindings/__pycache__/_cffi__x5eaa210axf0ae7e21.so

view raw
error.sh
hosted with ❤ by GitHub

To get around this, you’ll need to set some environment variables before installing cryptography:

# install via MacPorts
sudo port install openssl
sudo env ARCHFLAGS="-arch x86_64" LDFLAGS="-L/opt/local/lib" CFLAGS="-I/opt/local/include" pip install cryptography
# install via Homebrew
brew install openssl
env ARCHFLAGS="-arch x86_64" LDFLAGS="-L/usr/local/opt/openssl/lib" CFLAGS="-I/usr/local/opt/openssl/include" pip install cryptography

view raw
install.sh
hosted with ❤ by GitHub

A pull request has been opened to add this to the documentation but as of this writing it has not yet been merged.

Pytz 2013b Fails with PIP 1.4

UPDATE: Pytz is now using a numeric naming convention (i.e. 2013.7) which fixes this bug.

The latest version of PIP only installs stable versions by default, meaning anything with a pre-release version name will be ignored. Unfortunately the Pytz naming convention looks like a beta release (2013b) when it is actually the second release of 2013.

More on this bug can be found here:
https://bugs.launchpad.net/pytz/+bug/1204837

For now the workaround is to add the version when installing:

pip install pytz==2013b