dbr / tvdb_api

Simple to use interface to TheTVDB.com API in Python
The Unlicense
339 stars 63 forks source link

tvdb_api 3.1 still has "ImportError: cannot import name '_to_bytes' from 'requests_cache.backends.base'" bug #104

Open frank42hh opened 1 year ago

frank42hh commented 1 year ago
          Hi, I'm unsure why this still doesn't work here, so any hint appreciated.

I'm on a Manjaro system (22.0.0, Codename Sikaris) and installed via pacman:

To install (1):
  python-cattrs          22.2.0-2  (Required By: python-requests-cache)  community
To build (4):
  python-url-normalize   1.4.3-16                                        AUR
  python-requests-cache  0.9.7-1                                         AUR
  python-tvdb_api        3.1-1                                           AUR
  tvnamer                3.0.4-1                                         AUR

So, If I understand this thread correctly, _to_bytes is gone in requests-cache 0.9.7 but this is fixed in tvdb_api 3.1-1.

Nevertheless, I still get the same error:

ImportError: cannot import name '_to_bytes' from 'requests_cache.backends.base' (/usr/lib/python3.10/site-packages/requests_cache/backends/base.py)

And it seems that this has NOT been fixed in 3.1.0:

[freddy@hades ~]$ grep -E '__version|_to_bytes' /usr/lib/python3.10/site-packages/tvdb_api.py
__version__ = "3.1.0"
from requests_cache.backends.base import _to_bytes, _DEFAULT_HEADERS
    key.update(_to_bytes(request.method.upper()))
    key.update(_to_bytes(url))
        key.update(_to_bytes(body))
                    key.update(_to_bytes(name))
                    key.update(_to_bytes(value))

So, what's going wrong here? Did I miss something?

_Originally posted by @frank42hh in https://github.com/dbr/tvdb_api/issues/92#issuecomment-1373507386_

frank42hh commented 6 months ago

One year later, I would like to ask how this still can be an issue. Is there a "secret bugfix" I didn't detect yet or does no one bother that this awesome tool doesn't work anymore?

Current trace:

freddy@hades ~ % /usr/bin/distro
Name: Manjaro Linux
Version: 24.0.0 (Wynsdey)
Codename: Wynsdey

freddy@hades % pamac install tvnamer
To install (1):
  python-cattrs          23.2.3-3  (Required By: python-requests-cache)  extra
To build (4):
  python-url-normalize   1.4.3-17                                        AUR
  python-requests-cache  1.2.0-1                                         AUR
  python-tvdb_api        3.1-1                                           AUR
  tvnamer                3.0.4-1                                         AUR

And then:

freddy@hades S7 % tvnamer
Traceback (most recent call last):
  File "/usr/bin/tvnamer", line 33, in <module>
    sys.exit(load_entry_point('tvnamer==3.0.4', 'console_scripts', 'tvnamer')())
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/bin/tvnamer", line 25, in importlib_load_entry_point
    return next(matches).load()
           ^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/importlib/metadata/__init__.py", line 205, in load
    module = import_module(match.group('module'))
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/importlib/__init__.py", line 90, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "<frozen importlib._bootstrap>", line 1387, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1360, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1331, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 935, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 995, in exec_module
  File "<frozen importlib._bootstrap>", line 488, in _call_with_frames_removed
  File "/usr/lib/python3.12/site-packages/tvnamer/main.py", line 18, in <module>
    import tvdb_api
  File "/usr/lib/python3.12/site-packages/tvdb_api.py", line 34, in <module>
    from requests_cache.backends.base import _to_bytes, _DEFAULT_HEADERS
ImportError: cannot import name '_to_bytes' from 'requests_cache.backends.base' (/usr/lib/python3.12/site-packages/requests_cache/backends/base.py)

Any suggestion on how to make this work again is highly appreciated.