Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cannot import name 'remove_expired_responses' from 'requests_cache' #126

Closed
lucbettaieb opened this issue Feb 28, 2024 · 2 comments · Fixed by #127
Closed

cannot import name 'remove_expired_responses' from 'requests_cache' #126

lucbettaieb opened this issue Feb 28, 2024 · 2 comments · Fixed by #127
Milestone

Comments

@lucbettaieb
Copy link
Contributor

lucbettaieb commented Feb 28, 2024

python version: 3.10.12
pygbif version:

Name: pygbif
Version: 0.6.3
Summary: Python client for GBIF
Home-page: http://github.com/gbif/pygbif
Author: Scott Chamberlain
Author-email: myrmecocystus@gmail.com
License: MIT
Location: /usr/local/lib/python3.10/dist-packages
Requires: appdirs, geojson-rewind, geomet, matplotlib, requests, requests-cache
Required-by:

Getting the following error upon import:

    import pygbif
  File "/usr/local/lib/python3.10/dist-packages/pygbif/__init__.py", line 44, in <module>
    from .caching import caching
  File "/usr/local/lib/python3.10/dist-packages/pygbif/caching.py", line 6, in <module>
    from requests_cache import remove_expired_responses
ImportError: cannot import name 'remove_expired_responses' from 'requests_cache' (/usr/local/lib/python3.10/dist-packages/requests_cache/__init__.py)
@jmbarrios
Copy link

I believe this issue is fixed on PR #125

@jmbarrios
Copy link

This issue stems from the removal of the remove_expired_responses method in versions of requests-cache 1.2 and above. (See details at https://requests-cache.readthedocs.io/en/stable/project_info/history.html#id5)

Two workarounds address this problem:

  1. Incorporate the changes proposed by @lucbettaieb in pull request Fix for #126 as initially proposed by @bbrangeo; pushing for speed (since i need it.. :) ) #127.

  2. Update the requirements.txt file to restrict the requests-cache version to below 1.2. Add the following line:

    requests-cache<1.2
    

Option 2 ensures no other changes introduced in requests-cache version 1.2 are implemented, but it's important to note that the remove_expired_responses method is deprecated.

This issue currently impedes new installations of pygbif.

CecSve added a commit that referenced this issue Mar 1, 2024
Fix for #126 as initially proposed by @bbrangeo; pushing for speed (since i need it.. :) )
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants