Skip to content
This repository was archived by the owner on Jul 22, 2021. It is now read-only.
This repository was archived by the owner on Jul 22, 2021. It is now read-only.

file_cache is unavailable when using oauth2client >= 4.0.0 or google-auth #194

Open

Description

@thekillgfx
Traceback (most recent call last):
  File "/home/runner/.local/share/virtualenvs/python3/lib/python3.8/site-packages/googleapiclient/discovery_cache/file_cache.py", line 37, in <module>
    from oauth2client.locked_file import LockedFile
ModuleNotFoundError: No module named 'oauth2client.locked_file'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/runner/.local/share/virtualenvs/python3/lib/python3.8/site-packages/googleapiclient/discovery_cache/__init__.py", line 42, in autodetect
    from . import file_cache
  File "/home/runner/.local/share/virtualenvs/python3/lib/python3.8/site-packages/googleapiclient/discovery_cache/file_cache.py", line 40, in <module>
    raise ImportError(
ImportError: file_cache is unavailable when using oauth2client >= 4.0.0 or google-auth

Activity

  1. kuldeeprishi commented on Jul 3, 2020

    @kuldeeprishi

    is there any update on this?

  2. shcheklein commented on Jul 3, 2020

    @shcheklein

    @kuldeeprishi when does this error happen? could you give more context?

  3. Zukunftsmusik commented on Aug 4, 2020

    @Zukunftsmusik

    I'm getting the same error.
    According to googleapis/google-api-python-client#299 you either need to change the logging level
    import logging logging.getLogger('googleapiclient.discovery_cache').setLevel(logging.ERROR)
    or disable the cache adding cache_discovery=False in discover.build(api, version, http=http, cache_discovery=False)

    The former does not suffice imo. I don't wanna suppress warnings, I'd like them not to occur.
    The latter can't be done through PyDrive, it seems.

    For me this happens when I initialize the drive object multiple times (I have to do this, since the credential file gets deleted regularly on my hoster (Heroku)) and then try to list files on gdrive.

    Code

    Initializing

    gauth: pydrive.auth.GoogleAuth = pydrive.auth.GoogleAuth(settings_file=settings_file_path)
    credentials = pydrive.auth.ServiceAccountCredentials.from_json_keyfile_name(service_account_file_path, scopes)
    gauth.credentials = credentials
    drive: pydrive.drive.GoogleDrive = pydrive.drive.GoogleDrive(gauth)
    

    ListFiles

    This is where the error occurs, after having initialized the client 2 times in short succession.

    file_list = drive.ListFile({'q': f'\'{self._folder_id}\' in parents and title contains \'{file_name_part}\''}).GetList()
    

    Full error message

    [WARNING ] googleapiclient.discovery_cache: file_cache is unavailable when using oauth2client >= 4.0.0 or google-auth
    Traceback (most recent call last):
      File "/Users/[...]/.pyenv/versions/3.6.9/lib/python3.6/site-packages/googleapiclient/discovery_cache/__init__.py", line 36, in autodetect
        from google.appengine.api import memcache
    ModuleNotFoundError: No module named 'google.appengine'
    
    During handling of the above exception, another exception occurred:
    
    Traceback (most recent call last):
      File "/Users/[...]/.pyenv/versions/3.6.9/lib/python3.6/site-packages/googleapiclient/discovery_cache/file_cache.py", line 33, in <module>
        from oauth2client.contrib.locked_file import LockedFile
    ModuleNotFoundError: No module named 'oauth2client.contrib.locked_file'
    
    During handling of the above exception, another exception occurred:
    
    Traceback (most recent call last):
      File "/Users/[...]/.pyenv/versions/3.6.9/lib/python3.6/site-packages/googleapiclient/discovery_cache/file_cache.py", line 37, in <module>
        from oauth2client.locked_file import LockedFile
    ModuleNotFoundError: No module named 'oauth2client.locked_file'
    
    During handling of the above exception, another exception occurred:
    
    Traceback (most recent call last):
      File "/Users/[...]/.pyenv/versions/3.6.9/lib/python3.6/site-packages/googleapiclient/discovery_cache/__init__.py", line 42, in autodetect
        from . import file_cache
      File "/Users/[...]/.pyenv/versions/3.6.9/lib/python3.6/site-packages/googleapiclient/discovery_cache/file_cache.py", line 41, in <module>
        "file_cache is unavailable when using oauth2client >= 4.0.0 or google-auth"
    ImportError: file_cache is unavailable when using oauth2client >= 4.0.0 or google-auth
    
  4. shcheklein commented on Aug 4, 2020

    @shcheklein
  5. Zukunftsmusik commented on Aug 4, 2020

    @Zukunftsmusik

    That's odd. I'm running version 1.3.1 (updated 2016 according to PyPi) and the warning occurs.
    The file above has been changed in 2018.

    I'll try using git+https://github.com/googledrive/PyDrive.git#egg=PyDrive instead.

  6. Zukunftsmusik commented on Aug 4, 2020

    @Zukunftsmusik

    Yep, that did it.
    thx for the hint 👍

  7. shcheklein commented on Aug 4, 2020

    @shcheklein

    @Zukunftsmusik you can alternatively use PyDrive2 that we maintain. It has a lot of updates and other fixes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions