lcosmin / boardgamegeek

A Python interface to boardgamegeek.com. Pulls information from BGG and creates Python objects for the data.
BSD 3-Clause "New" or "Revised" License
117 stars 71 forks source link

Problem with request_cache #67

Open Irazall opened 3 years ago

Irazall commented 3 years ago

I get the following error message:

Traceback (most recent call last):
  File "<input>", line 1, in <module>
  File "/home/irazall/.local/share/JetBrains/Toolbox/apps/PyCharm-P/ch-0/211.7142.13/plugins/python/helpers/pydev/_pydev_bundle/pydev_import_hook.py", line 21, in do_import
    module = self._system_import(name, *args, **kwargs)
  File "/home/irazall/promotion/it/python-projects/envs/dynamic_pricing/lib/python3.8/site-packages/boardgamegeek/__init__.py", line 10, in <module>
    from .api import BGGClient, BGGChoose, BGGRestrictDomainTo, BGGRestrictPlaysTo, BGGRestrictSearchResultsTo, BGGRestrictCollectionTo
  File "/home/irazall/.local/share/JetBrains/Toolbox/apps/PyCharm-P/ch-0/211.7142.13/plugins/python/helpers/pydev/_pydev_bundle/pydev_import_hook.py", line 21, in do_import
    module = self._system_import(name, *args, **kwargs)
  File "/home/irazall/promotion/it/python-projects/envs/dynamic_pricing/lib/python3.8/site-packages/boardgamegeek/api.py", line 703, in <module>
    class BGGClient(BGGCommon):
  File "/home/irazall/promotion/it/python-projects/envs/dynamic_pricing/lib/python3.8/site-packages/boardgamegeek/api.py", line 727, in BGGClient
    def __init__(self, cache=CacheBackendMemory(ttl=3600), timeout=15, retries=3, retry_delay=5, disable_ssl=False, requests_per_minute=DEFAULT_REQUESTS_PER_MINUTE):
  File "/home/irazall/promotion/it/python-projects/envs/dynamic_pricing/lib/python3.8/site-packages/boardgamegeek/cache.py", line 23, in __init__
    self.cache = requests_cache.core.CachedSession(backend="memory", expire_after=ttl, allowable_codes=(200,))
AttributeError: module 'requests_cache' has no attribute 'core'

I assume that some dependencies are deprecated. Thanks anyway for implementing this tool!

Irazall commented 3 years ago

https://github.com/reclosedev/requests-cache/blob/master/requests_cache/core.py This should be the solution

giannimastroscianni commented 3 years ago

Exactly. Just remove 'core' and import CachedSession directly from requests_cache

JWCook commented 3 years ago

You can blame me for that one, sorry! The intent for this was to raise a DeprecationWarning instead of causing an error. This would have worked if imported as from requests_cache.core import CachedSession; using requests_cache.core.CachedSession wasn't something I thought of.

If you run into any more problems, feel free to create an issue on the requests-cache repo.

rsmassey commented 1 year ago

Hi, I'm having the same problem, but I'm not sure how to solve it.

SukiCZ commented 7 months ago

Hi @rsmassey

As stated in the last commit 37f74d9 the maintainer will not continue his work so I've created a fork here, the library can be installed from PyPi with updated docs and more.

Feel free to install updated library instead (pip install bgg-api), that should fix your issue. Contributions are welcome ❤️ thanks!