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

can't use caching: AttributeError: module 'requests_cache' has no attribute 'delete' #145

Closed
abubelinha opened this issue May 1, 2024 · 7 comments

Comments

@abubelinha
Copy link

abubelinha commented May 1, 2024

Python 3.8.7, pygbif 0.6.4:

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.
>>> import pygbif
>>> pygbif.__version__
'0.6.4'
>>> pygbif.caching(True)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\\Python38\lib\site-packages\pygbif\caching.py", line 86, in caching
    requests_cache.delete(expired=True)
AttributeError: module 'requests_cache' has no attribute 'delete'

I saw some other issues about requests_cache and they are closed, so I understand they have been solved.
But I think my pygbif version is the most recent available.
Any ideas?

@CecSve
Copy link
Contributor

CecSve commented May 1, 2024

@jhnwllr can you investigate this when you have a chance?

@abubelinha
Copy link
Author

For now I downgraded to pygbif 0.6.3 and my above lines do not raise any errors.

I think this was the origin of the problem because it introduced the above error line 86:
#127

requests_cache.delete(expired=True)

@jhnwllr
Copy link
Contributor

jhnwllr commented May 1, 2024

@abubelinha Can I ask what version of the requests_cache library you are using?

We might need to update the minimum version in requirements.txt.

I am using requests_cache 1.2.0.

And I don't get any error on import.

@abubelinha
Copy link
Author

>>> import requests_cache
>>> requests_cache.__version__
'1.0.0'

@jhnwllr
Copy link
Contributor

jhnwllr commented May 1, 2024

@abubelinha
I can reproduce the error when I downgrade requests_cache enough

Type "help", "copyright", "credits" or "license" for more information.
>>> import pygbif        
>>> pygbif.__version__
'0.6.4'
>>> pygbif.caching(True)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Users\ftw712\Desktop\packages\pygbif\pygbif\caching.py", line 86, in caching
    requests_cache.delete(expired=True)
    ^^^^^^^^^^^^^^^^^^^^^
AttributeError: module 'requests_cache' has no attribute 'delete'
>>> import requests_cache 
>>> requests_cache.__version__ 
'0.7.0'
>>>

@lucbettaieb
Copy link
Contributor

Can this be fixed by updating the requirements.txt line for requests-cache to then be >=1.2.0?

Would be an easy fix, then.

@abubelinha
Copy link
Author

Thanks @CecSve , @jhnwllr and @lucbettaieb

  • I upgraded requests_cache to 1.2.0.
  • Then I upgraded pygbif to 0.6.4

Now I can call pygbif.caching(True) and "it works", since there is no error message.

But caching is proving to be useless for my use case (see #146).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants