Cryptography: Windows Wheels don't work.

Created on 8 Mar 2014  Â·  17Comments  Â·  Source: pyca/cryptography

Hi there,

the Windows wheel for cryptography on PyPI doesn't work.
While it installs properly, it requires the msvc compiler on its first run.

C:\Python27\Scripts>pip install https://pypi.python.org/packages/cp27/c/cryptogr
aphy/cryptography-0.2.2-cp27-none-win32.whl#md5=7f3979da8340a7fe3aa859d3bfc1a5f1
[...]
Successfully installed cryptography cffi six pycparser
Cleaning up...
C:\Python27>python
Python 2.7.6 (default, Nov 10 2013, 19:24:18) [MSC v.1500 32 bit (Intel)] on win
32
Type "help", "copyright", "credits" or "license" for more information.
>>> from cryptography import fernet
Traceback (most recent call last):
  File "", line 1, in 
  File "C:\Python27\lib\site-packages\cryptography\fernet.py", line 23, in 
    from cryptography.hazmat.backends import default_backend
  File "C:\Python27\lib\site-packages\cryptography\hazmat\backends\__init__.py",
 line 14, in 
    from cryptography.hazmat.backends import openssl
  File "C:\Python27\lib\site-packages\cryptography\hazmat\backends\openssl\__ini
t__.py", line 14, in 
    from cryptography.hazmat.backends.openssl.backend import backend
  File "C:\Python27\lib\site-packages\cryptography\hazmat\backends\openssl\backe
nd.py", line 564, in 
    backend = Backend()
  File "C:\Python27\lib\site-packages\cryptography\hazmat\backends\openssl\backe
nd.py", line 48, in __init__
    self._binding = Binding()
  File "C:\Python27\lib\site-packages\cryptography\hazmat\bindings\openssl\bindi
ng.py", line 83, in __init__
    self._ensure_ffi_initialized()
  File "C:\Python27\lib\site-packages\cryptography\hazmat\bindings\openssl\bindi
ng.py", line 99, in _ensure_ffi_initialized
    libraries)
  File "C:\Python27\lib\site-packages\cryptography\hazmat\bindings\utils.py", li
ne 72, in build_ffi
    ext_package="cryptography",
  File "C:\Python27\lib\site-packages\cffi\api.py", line 341, in verify
    lib = self.verifier.load_library()
  File "C:\Python27\lib\site-packages\cffi\verifier.py", line 74, in load_librar
y
    self._compile_module()
  File "C:\Python27\lib\site-packages\cffi\verifier.py", line 139, in _compile_m
odule
    outputfilename = ffiplatform.compile(tmpdir, self.get_extension())
  File "C:\Python27\lib\site-packages\cffi\ffiplatform.py", line 25, in compile
    outputfilename = _build(tmpdir, ext)
  File "C:\Python27\lib\site-packages\cffi\ffiplatform.py", line 47, in _build
    dist.run_command('build_ext')
  File "C:\Python27\lib\distutils\dist.py", line 972, in run_command
    cmd_obj.run()
  File "C:\Python27\lib\distutils\command\build_ext.py", line 337, in run
    self.build_extensions()
  File "C:\Python27\lib\distutils\command\build_ext.py", line 446, in build_exte
nsions
    self.build_extension(ext)
  File "C:\Python27\lib\distutils\command\build_ext.py", line 496, in build_exte
nsion
    depends=ext.depends)
  File "C:\Python27\lib\distutils\msvc9compiler.py", line 473, in compile
    self.initialize()
  File "C:\Python27\lib\distutils\msvc9compiler.py", line 383, in initialize
    vc_env = query_vcvarsall(VERSION, plat_spec)
  File "C:\Python27\lib\distutils\msvc9compiler.py", line 271, in query_vcvarsal
l
    raise DistutilsPlatformError("Unable to find vcvarsall.bat")
distutils.errors.DistutilsPlatformError: Unable to find vcvarsall.bat

With Visual Studio 9 installed, I end up with

_cffi__x969a4f6ex69432c5f.c
C:\Python27\lib\site-packages\cryptography\hazmat\bindings\__pycache__\_cffi__x9
69a4f6ex69432c5f.c(165) : fatal error C1083: Cannot open include file: 'openssl/
aes.h': No such file or directory
Traceback (most recent call last):
  File "", line 1, in 
  File "C:\Python27\lib\site-packages\cryptography\fernet.py", line 23, in 
    from cryptography.hazmat.backends import default_backend
  File "C:\Python27\lib\site-packages\cryptography\hazmat\backends\__init__.py",
 line 14, in 
    from cryptography.hazmat.backends import openssl
  File "C:\Python27\lib\site-packages\cryptography\hazmat\backends\openssl\__ini
t__.py", line 14, in 
    from cryptography.hazmat.backends.openssl.backend import backend
  File "C:\Python27\lib\site-packages\cryptography\hazmat\backends\openssl\backe
nd.py", line 564, in 
    backend = Backend()
  File "C:\Python27\lib\site-packages\cryptography\hazmat\backends\openssl\backe
nd.py", line 48, in __init__
    self._binding = Binding()
  File "C:\Python27\lib\site-packages\cryptography\hazmat\bindings\openssl\bindi
ng.py", line 83, in __init__
    self._ensure_ffi_initialized()
  File "C:\Python27\lib\site-packages\cryptography\hazmat\bindings\openssl\bindi
ng.py", line 99, in _ensure_ffi_initialized
    libraries)
  File "C:\Python27\lib\site-packages\cryptography\hazmat\bindings\utils.py", li
ne 72, in build_ffi
    ext_package="cryptography",
  File "C:\Python27\lib\site-packages\cffi\api.py", line 341, in verify
    lib = self.verifier.load_library()
  File "C:\Python27\lib\site-packages\cffi\verifier.py", line 74, in load_librar
y
    self._compile_module()
  File "C:\Python27\lib\site-packages\cffi\verifier.py", line 139, in _compile_m
odule
    outputfilename = ffiplatform.compile(tmpdir, self.get_extension())
  File "C:\Python27\lib\site-packages\cffi\ffiplatform.py", line 25, in compile
    outputfilename = _build(tmpdir, ext)
  File "C:\Python27\lib\site-packages\cffi\ffiplatform.py", line 50, in _build
    raise VerificationError('%s: %s' % (e.__class__.__name__, e))
cffi.ffiplatform.VerificationError: CompileError: command '"C:\Program Files (x8
6)\Microsoft Visual Studio 9.0\VC\BIN\cl.exe"' failed with exit status 2

Any pointers on how to fix that would be appreciated.

Thanks,
Max

bugs

Most helpful comment

'openssl/opensslv.h': No such file or directory

dcl-lily, please try
python -m pip install --upgrade pip
and
pip2 install cryptography
I had same today

All 17 comments

Could you give us some details about your configuration? What version of windows and version of OpenSSL you installed? It's quite possible we're doing something wrong here, so this may take some investigation.

Hi there,

thanks for the quick reply. Windows 8.1 and Win32 OpenSSL v1.0.1f from http://slproweb.com/products/Win32OpenSSL.html installed with default settings (to C:\OpenSSL-Win32).
The original error (before it gets substituted by the except handler at cffi.ffiplatform.py@49) is

cryptography\hazmat\bindings\__pycache__\_cffi__x969a4f6ex69432c5f.c(165) : fata
l error C1083: Cannot open include file: 'openssl/aes.h': No such file or direct
ory

If i set LIB and INCLUDE correctly and install from source, everything works.

Cheers,
Max

I have been able to replicate this, but I'm not sure why it's occurring.

It looks like this is caused by the version of cffi we built 0.2.2 against (0.8.1) vs the version you presumably have installed (0.8.2). As a workaround you can do pip install -I cffi==0.8.1, but we'll be looking for a real solution.

I've filed https://bitbucket.org/cffi/cffi/issue/140/ to start talking with the cffi authors about a solution to this.

Thanks for the quick reply. Excellent work :thumbsup:

On Mar 9, 2014, at 9:51 AM, Paul Kehrer [email protected] wrote:

It looks like this is caused by the version of cffi we built 0.2.2 against (0.8.1) vs the version you presumably have installed (0.8.2). As a workaround you can do pip install -I cffi==0.8.1, but we'll be looking for a real solution.

—
Reply to this email directly or view it on GitHub.

Yes, cffi puts the exact cffi version in the hash for the filename it looks for. I think we can work around this by specifying our own name. If not then we need to probably pin to an exact version. Ideally cffi would fix this.

This should be fixed with today's release!

Works For Me! ^_^

Can somebody help me here .. whenever i installed pyapns, apns-client .. using pip on windows i run into this issue mentioned above .. how did you guys solve this issue ?

i tried this but nthing changed :pip install -I cffi==0.8.1...i still get the same error

File "C:\Python27\lib\site-packages\cffi\ffiplatform.py", line 50, in _build
raise VerificationError('%s: %s' % (e.__class__.name, e))
cffi.ffiplatform.VerificationError: CompileError: command '"C:\Program Files (x8
6)\Microsoft Visual Studio 9.0\VC\BIN\cl.exe"' failed with exit status 2

Any pointers on how to fix that would be appreciated.

if i use easy install i get

cryptography\hazmat\bindings__pycache___Cryptography_cffi_79a5b0a3x3a8a382.c(165) : fatal error C1083: Cannot open include file: 'openssl/aes.
h': No such file or directory
error: c:\users\njainappdata\local\temp\easy_install-rx23qq\cryptography-0.5.2\cryptography\hazmat\primitives__pycache___Cryptography_cffi_68
4bb40axf342507b.pyd: Access is denied

That looks like it's not installing the wheel. Be sure you're running an up-to-date copy of pip. What version are you running now?

I used pip install -I cffi==0.8.1, but when I used easy_install requests[security], It's already have this error

This issue is a year old and the cffi problem described above is not an issue with current versions of cryptography. If you are getting an error claiming it can't find vcvarsall or a compiler please verify that your version of pip is the latest. Versions of pip older than 1.5 do not install wheels by default.

Additionally, easy_install does not support wheels at all (as well as being a deprecated and inadvisable way to install python packages).

I used pip install requests[security], It's success. thinks for your help.

_openssl.c
build\temp.win-amd64-2.7\Release_openssl.c(429) : fatal error C1083: Cannot open include file: 'openssl/opensslv.h': No such file or directory
error: [Error 5] : 'c:\users\alexappdata\local\tempeasy_install-lr3blj\cryptography-1.4.eggs\cffi-1.7.0-py2.7-win-amd64.egg_cffi_backend.pyd'

'openssl/opensslv.h': No such file or directory

dcl-lily, please try
python -m pip install --upgrade pip
and
pip2 install cryptography
I had same today

Was this page helpful?
0 / 5 - 0 ratings

Related issues

clarius-deploy picture clarius-deploy  Â·  22Comments

mhils picture mhils  Â·  28Comments

ShaneHarvey picture ShaneHarvey  Â·  20Comments

abhishek-ram picture abhishek-ram  Â·  37Comments

freedge picture freedge  Â·  22Comments