guessit-io / guessit

GuessIt is a python library that extracts as much information as possible from a video filename.
https://guessit-io.github.io/guessit
GNU Lesser General Public License v3.0
814 stars 92 forks source link

python3.10: "AttributeError: module 'collections' has no attribute 'MutableMapping'" #713

Closed sanderjo closed 2 years ago

sanderjo commented 2 years ago

As described in https://github.com/sabnzbd/sabnzbd/issues/1971#issuecomment-958121843

$ python3.10
Python 3.10.0 (default, Oct  4 2021, 22:09:55) [GCC 9.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import guessit
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/sander/.local/lib/python3.10/site-packages/guessit/__init__.py", line 8, in <module>
    from .api import guessit, GuessItApi
  File "/home/sander/.local/lib/python3.10/site-packages/guessit/api.py", line 17, in <module>
    from .rules import rebulk_builder
  File "/home/sander/.local/lib/python3.10/site-packages/guessit/rules/__init__.py", line 11, in <module>
    from .properties.episodes import episodes
  File "/home/sander/.local/lib/python3.10/site-packages/guessit/rules/properties/episodes.py", line 16, in <module>
    from .title import TitleFromPosition
  File "/home/sander/.local/lib/python3.10/site-packages/guessit/rules/properties/title.py", line 11, in <module>
    from .language import (
  File "/home/sander/.local/lib/python3.10/site-packages/guessit/rules/properties/language.py", line 10, in <module>
    import babelfish
  File "/usr/lib/python3/dist-packages/babelfish/__init__.py", line 20, in <module>
    from .converters import (LanguageConverter, LanguageReverseConverter, LanguageEquivalenceConverter, CountryConverter,
  File "/usr/lib/python3/dist-packages/babelfish/converters/__init__.py", line 11, in <module>
    class CaseInsensitiveDict(collections.MutableMapping):
AttributeError: module 'collections' has no attribute 'MutableMapping'
>>> 

I think I'm uptodate with my pip modules:

$ python3.10 -m pip install guessit -U
Defaulting to user installation because normal site-packages is not writeable
Requirement already satisfied: guessit in /home/sander/.local/lib/python3.10/site-packages (3.3.1)
Requirement already satisfied: rebulk>=3 in /home/sander/.local/lib/python3.10/site-packages (from guessit) (3.0.1)
Requirement already satisfied: babelfish in /usr/lib/python3/dist-packages (from guessit) (0.5.4)
Requirement already satisfied: python-dateutil in /usr/lib/python3/dist-packages (from guessit) (2.7.3)

FWIW:

$ python3.8
Python 3.8.10 (default, Sep 28 2021, 16:10:42) 
[GCC 9.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import collections
>>> collections.MutableMapping
<stdin>:1: DeprecationWarning: Using or importing the ABCs from 'collections' instead of from 'collections.abc' is deprecated since Python 3.3, and in 3.10 it will stop working
<class 'collections.abc.MutableMapping'>
>>> 
>>> collections.abc.MutableMapping
<class 'collections.abc.MutableMapping'>
>>> 

Is this something that should be solved in guessit?

sanderjo commented 2 years ago

Oh, wait ... babelfish?

$ python3.10
Python 3.10.0 (default, Oct  4 2021, 22:09:55) [GCC 9.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import babelfish
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python3/dist-packages/babelfish/__init__.py", line 20, in <module>
    from .converters import (LanguageConverter, LanguageReverseConverter, LanguageEquivalenceConverter, CountryConverter,
  File "/usr/lib/python3/dist-packages/babelfish/converters/__init__.py", line 11, in <module>
    class CaseInsensitiveDict(collections.MutableMapping):
AttributeError: module 'collections' has no attribute 'MutableMapping'
>>> 

Let's update babelfish:

$ python3.10 -m pip install babelfish -U
Defaulting to user installation because normal site-packages is not writeable
Requirement already satisfied: babelfish in /usr/lib/python3/dist-packages (0.5.4)
Collecting babelfish
  Downloading babelfish-0.6.0-py3-none-any.whl (93 kB)
     |████████████████████████████████| 93 kB 425 kB/s            
Installing collected packages: babelfish
Successfully installed babelfish-0.6.0
$ python3.10
Python 3.10.0 (default, Oct  4 2021, 22:09:55) [GCC 9.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import babelfish
>>

Good!