iterative / PyDrive2

Google Drive API Python wrapper library. Maintained fork of PyDrive.
https://docs.iterative.ai/PyDrive2
Other
570 stars 70 forks source link

error: from pydrive2.auth import GoogleAuth #290

Closed abubelinha closed 8 months ago

abubelinha commented 1 year ago

I have a script that I use once a year or so. Usually the only problem I have is needing to regenerate my credentials .txt file if it has expired.

But today I hit an error I had not seen before. It seems to be related to the OAuth made easy 1st step:

C:\Users\abu\AppData\Local\Programs\Python\Python38\python
Python 3.8.7 (tags/v3.8.7:6503f05, Dec 21 2020, 17:59:51) [MSC v.1928 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> from pydrive2.auth import GoogleAuth
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Users\abu\AppData\Local\Programs\Python\Python38\lib\site-packages\pydrive2\auth.py", line 7, in <module>
    from googleapiclient.discovery import build
  File "C:\Users\abu\AppData\Local\Programs\Python\Python38\lib\site-packages\googleapiclient\discovery.py", line 60, in <module>
    from googleapiclient import _auth
  File "C:\Users\abu\AppData\Local\Programs\Python\Python38\lib\site-packages\googleapiclient\_auth.py", line 34, in <module>
    import oauth2client.client
  File "C:\Users\abu\AppData\Local\Programs\Python\Python38\lib\site-packages\oauth2client\client.py", line 45, in <module>
    from oauth2client import crypt
  File "C:\Users\abu\AppData\Local\Programs\Python\Python38\lib\site-packages\oauth2client\crypt.py", line 45, in <module>
    from oauth2client import _openssl_crypt
  File "C:\Users\abu\AppData\Local\Programs\Python\Python38\lib\site-packages\oauth2client\_openssl_crypt.py", line 16, in <module>
    from OpenSSL import crypto
  File "C:\Users\abu\AppData\Local\Programs\Python\Python38\lib\site-packages\OpenSSL\__init__.py", line 8, in <module>
    from OpenSSL import crypto, SSL
  File "C:\Users\abu\AppData\Local\Programs\Python\Python38\lib\site-packages\OpenSSL\crypto.py", line 1556, in <module>
    class X509StoreFlags(object):
  File "C:\Users\abu\AppData\Local\Programs\Python\Python38\lib\site-packages\OpenSSL\crypto.py", line 1577, in X509StoreFlags
    CB_ISSUER_CHECK = _lib.X509_V_FLAG_CB_ISSUER_CHECK
AttributeError: module 'lib' has no attribute 'X509_V_FLAG_CB_ISSUER_CHECK'
>>> from importlib.metadata import version
>>> version('pydrive2')
'1.16.0'

I use Windows 7, Python 3.8.7, and my PyDrive2 version is the last release 1.16.0. Any hints? Should I upgrade some other libraries?

Thanks a lot in advance @abubelinha

shcheklein commented 1 year ago

@abubelinha from just a brief google https://stackoverflow.com/questions/73830524/attributeerror-module-lib-has-no-attribute-x509-v-flag-cb-issuer-check ?

abubelinha commented 1 year ago

Thanks @shcheklein , I had already seen that but I don't understand it.
I had not changed pip or any other things since the last time I used my PyDrive2 script. Have you also had to upgrade pip or pyopenssl at some point during the last year to keep using PyDrive2?

shcheklein commented 1 year ago

Have you also had to upgrade pip or pyopenssl at some point during the last year to keep using PyDrive2?

Not that I'm aware of tbh.

abubelinha commented 1 year ago

Could you please check your pyopenssl version? Mine seems to be 20.0.1

pip show pyopenssl
Name: pyOpenSSL
Version: 20.0.1
Summary: Python wrapper module around the OpenSSL library
Home-page: https://pyopenssl.org/
Author: The pyOpenSSL developers
Author-email: cryptography-dev@python.org
License: Apache License, Version 2.0
Location: c:\users\abu\appdata\local\programs\python\python38\lib\site-packages
Requires: cryptography, six
Required-by: PyDrive2
abubelinha commented 1 year ago

Nevermind. Thanks @shcheklein The problem solved with:

pip install --upgrade pyopenssl

and now:

pip show pyopenssl
Name: pyOpenSSL
Version: 23.2.0
Summary: Python wrapper module around the OpenSSL library
Home-page: https://pyopenssl.org/
Author: The pyOpenSSL developers
Author-email: cryptography-dev@python.org
License: Apache License, Version 2.0
Location: c:\users\abu\appdata\local\programs\python\python38\lib\site-packages
Requires: cryptography
Required-by: PyDrive2

What I don't understand is:
Shouldn't pyopenssl have already been upgraded to the required version when I upgraded pydrive2 just a few minutes before?

shcheklein commented 1 year ago

PyDrive specifies it as pyOpenSSL >= 19.1.0 . I'm not sure if there is a need to bump the requirement, since I don't know what was the underlying issue. Was there some critical error in the previous version that got fixed?

abubelinha commented 1 year ago

No idea. I just know what I mentioned above. All this is pretty obscure to me.

It seems pyopenssl was installed in my system when I first installed PyDrive (or PyDrive2), since no other packages required it. But at some point (today) PyDrive2 failed to work properly despite my pyopenssl was 20.0.1 > 19.1.0, as I described Did you check your installed version?

EDIT: Anyway, my PyDrive2 script works again after the pyopenssl upgrade, so it is not an issue for me anymore. Don't know if all this means requirements should be changed or not. Feel free to close the issue when you decide.