9

I'm get the following error when running pip install cryptography:

build\temp.win32-2.7\Release\_openssl.c(434) : fatal error C1083: Cannot open include file: 'openssl/opensslv.h': No such file or directory

I'm running windows 10, 64 bit, with python 2.7. I'm trying to install cryptography 1.9.

phd
  • 82,685
  • 13
  • 120
  • 165
theicfire
  • 2,719
  • 2
  • 26
  • 29
  • Answer here solved this issue for me and for other folks too https://stackoverflow.com/questions/22073516/failed-to-install-python-cryptography-package-with-pip-and-setup-py/22210069#comment52644528_22210069 – Aziz Mansaray Jan 04 '21 at 20:05

2 Answers2

28

Installing openssl and changing environment variables fixed this problem for me.

  • Install OpenSSL by using the installer from here: https://slproweb.com/products/Win32OpenSSL.html
  • Use the Win32OpenSSL-1_1_0f, even if your system is 64 bit (I tried installing the 64 bit version of OpenSSL and this did not fix the problem)
  • The following two folders should now exist: C:\OpenSSL-Win32\include, C:\OpenSSL-Win32\lib
  • Open a cmd line terminal and run the following:
  • > set INCLUDE=C:\OpenSSL-Win32\include;%INCLUDE%
  • > set LIB=C:\OpenSSL-Win32\lib;%LIB%
  • > pip install cryptography
theicfire
  • 2,719
  • 2
  • 26
  • 29
  • 1
    Worked fine on windows 10 x64, but when I tried the same inside virtual environment - there were the same error – Omkommersind Oct 17 '19 at 14:33
  • Same for me @Omkommersind Did you find a solution? – WJA Apr 10 '20 at 15:30
  • @JohnAndrews I decided to move everything to ubuntu to avoid such problems – Omkommersind Apr 11 '20 at 16:06
  • 3
    Using `git bash` (MINGW64) on Windows 10 64bit, I managed to get it working in my virtualenv with: 1. `export LIB="C:\OpenSSL-win64\lib"`, 2. `export INCLUDE="C:\OpenSSL-win64\include"` and then installing the library which made use of `cryptography` with `pip install ...` (And yes, I actually NEEDED the 64 bit version of OpenSSL because the 32 bit version did not work in my case). Used python 3.8.3 – ElectRocnic Sep 28 '20 at 19:13
  • 2
    I don't understand why I have to install the lib in order to install the cryptography package in mu venv. I did install it system wide (outside of venv) using the same python version and pip and it worked. I did not need to install OpenSSL. I don't want to have to install unnecessary things. Moreover this is not ideal because the generated requirements.txt most likely won't work on other machine as it will also require the "side installation" of the OpenSSL. – João Portela Oct 16 '20 at 10:19
  • Nice, same solution for https://pypi.org/project/pycookiecheat/, thanks – Ariel Dec 09 '20 at 16:47
  • I'm using scrapy which relies on cryptography. I wanted to use scrapy in a VENV but it failed because of cryptography. So what worked for me was: - Installing cryptography without VENV - Creating a venv which inherits global site packages - Installing scrapy – maniac Mar 09 '21 at 14:09
  • Just ran into this today, had success with Win64 OpenSSL v1.1.1m (win 64!!) and editing my environment variables through the windows menus (and not the command line) so they would be available everywhere. It installed in a different folder than OP by default so double check it. – Bradleo Dec 21 '21 at 10:50
1

I had the same problem on Fusion, which was resolved by upgrading pip.

val
  • 139
  • 1
  • 6
  • To add a little more color... My venv had a version of pip that did not support wheels, and so it tried to download the source and compile. After upgrading pip, the wheel was downloaded and installed no problem. – Charles L. Oct 05 '22 at 16:56