'No crypto library available' error on Windows | The "crypt" module is UNIX specific :-/

1,179 views
Skip to first unread message

Patrice

unread,
Mar 22, 2015, 11:51:34 PM3/22/15
to google-api-p...@googlegroups.com
I was trying to run the line

credentials = SignedJwtAssertionCredentials(client_email, private_key, 'https://www.googleapis.com/auth/compute')

on my Windows laptop, but got the error

No crypto library available

Googling the error, I find out that I had to install pyOpenSSL, that I did:

>>> import ssl
>>> ssl.OPENSSL_VERSION
'OpenSSL 0.9.8y 5 Feb 2013'

But, it did not fix the error above, so I looked in more details to the error message:

Traceback (most recent call last):
  File "<pyshell#35>", line 1, in <module>
    credentials = SignedJwtAssertionCredentials(client_email, private_key, 'https://www.googleapis.com/auth/compute')
  File "C:\python27_x64\lib\site-packages\oauth2client-1.4.7-py2.7.egg\oauth2client\util.py", line 137, in positional_wrapper
    return wrapped(*args, **kwargs)
  File "C:\python27_x64\lib\site-packages\oauth2client-1.4.7-py2.7.egg\oauth2client\client.py", line 1458, in __init__
    _RequireCryptoOrDie()
  File "C:\python27_x64\lib\site-packages\oauth2client-1.4.7-py2.7.egg\oauth2client\client.py", line 1412, in _RequireCryptoOrDie
    raise CryptoUnavailableError('No crypto library available')
CryptoUnavailableError: No crypto library available

Therefore, I went to the line 1458 in "client.py" that I found at https://github.com/google/oauth2client/blob/master/oauth2client/client.py to, indeed, find:

_RequireCryptoOrDie()

Then, I looked up the definition of this function that I found from line 1404:

def _RequireCryptoOrDie():
  """Ensure we have a crypto library, or throw CryptoUnavailableError.
  The oauth2client.crypt module requires either PyCrypto or PyOpenSSL
  to be available in order to function, but these are optional
  dependencies.
  """
  if not HAS_CRYPTO:
    raise CryptoUnavailableError('No crypto library available')

Then, I looked up for the "definition" of HAS_CRYPTO that I found from line 44:

HAS_CRYPTO = False
try:
  from oauth2client import crypt
  HAS_CRYPTO = True

With that information, I tried to interactively import the "crypt" module:

>>> import crypt
Traceback (most recent call last):
  File "<pyshell#41>", line 1, in <module>
    import crypt
ImportError: No module named crypt

And trying to find how to install the "crypt" module of my Windows laptop, I found out that "crypt" is a Unix specific module that I can't install on my Windows laptop, see http://stackoverflow.com/questions/19877867/using-the-crypt-module-in-windows :-/

As a conclusion, if the "Google APIs Client Library for Python" requires the "crypt" module, and the "crypt" module cannot be used/installed on Windows OS, then the "Google APIs Client Library for Python" cannot be used on Windows OS, which is in contradiction with the documentation at https://developers.google.com/api-client-library/python/start/installation, which includes Windows as supported OS.

Have I missed something? I am just starting playing with Python... Or, should the "client.py" be adapted?

Many thanks in advance for your help!

TJ Davis

unread,
May 20, 2015, 4:02:17 PM5/20/15
to google-api-p...@googlegroups.com

Patrice - Did you find a solution to this?  I am having the same problem.  I see other forums where people suggest that it works with pyOpenSSL but I'm seeing what you mentioned.  I am able to import OpenSSL.SSL and OpenSSL.crypto but I get the "no crypto library available" message when making calls to the Google API.
Reply all
Reply to author
Forward
0 new messages