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

Python 3.11 support #19

Closed
aatemes opened this issue Mar 6, 2023 · 3 comments
Closed

Python 3.11 support #19

aatemes opened this issue Mar 6, 2023 · 3 comments
Labels
enhancement New feature or request

Comments

@aatemes
Copy link

aatemes commented Mar 6, 2023

Добрый день!

HA Core.
После обновления на HA 2023.3.1 и Python 3.11.2 перестал работать компонент MorphNumbers.
Гугл говорит, что это связано как раз с Python 3.11...

2023-03-06 15:58:39.933 ERROR (MainThread) [homeassistant.loader] Unexpected exception importing component custom_components.morph_numbers
Traceback (most recent call last):
  File "/srv/homeassistant/lib/python3.11/site-packages/homeassistant/loader.py", line 760, in get_component
    cache[self.domain] = importlib.import_module(self.pkg_path)
                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "<frozen importlib._bootstrap>", line 1206, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1178, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1149, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 690, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 940, in exec_module
  File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
  File "/home/homeassistant/.homeassistant/custom_components/morph_numbers/__init__.py", line 10, in <module>
    MORPH = MorphNumber()
            ^^^^^^^^^^^^^
  File "/home/homeassistant/.homeassistant/custom_components/morph_numbers/utils.py", line 47, in __init__
    morph = MorphAnalyzer()
            ^^^^^^^^^^^^^^^
  File "/srv/homeassistant/lib/python3.11/site-packages/pymorphy2/analyzer.py", line 224, in __init__
    self._init_units(units)
  File "/srv/homeassistant/lib/python3.11/site-packages/pymorphy2/analyzer.py", line 235, in _init_units
    self._units.append((self._bound_unit(unit), False))
                        ^^^^^^^^^^^^^^^^^^^^^^
  File "/srv/homeassistant/lib/python3.11/site-packages/pymorphy2/analyzer.py", line 246, in _bound_unit
    unit = unit.clone()
           ^^^^^^^^^^^^
  File "/srv/homeassistant/lib/python3.11/site-packages/pymorphy2/units/base.py", line 35, in clone
    return self.__class__(**self._get_params())
                            ^^^^^^^^^^^^^^^^^^
  File "/srv/homeassistant/lib/python3.11/site-packages/pymorphy2/units/base.py", line 76, in _get_params
    (key, getattr(self, key, None)) for key in self._get_param_names()
                                               ^^^^^^^^^^^^^^^^^^^^^^^
  File "/srv/homeassistant/lib/python3.11/site-packages/pymorphy2/units/base.py", line 70, in _get_param_names
    args, varargs, kw, default = inspect.getargspec(cls.__init__)
                                 ^^^^^^^^^^^^^^^^^^
AttributeError: module 'inspect' has no attribute 'getargspec'
@malinovsku
Copy link

аналогичная проблема при обновлении Home Assistant до 2023.6.*, так как обновлен Python до 3.11, как понял библиотека pymorphy2 мертва и есть fork с исправлением https://github.com/no-plagiarism/pymorphy3 , в файлах компонента изменил везде pymorphy2 на pymorphy3 и все успешно работает в HA

@notabene00
Copy link

Подтверждаю, переход на то, что теперь называет себя pymorphy3, решило проблему после обновления на python3.11 (установки 2023.06).
Исправлено 2 на 3 в манифесте и две строки импорта в utils.py.

@AlexxIT
Copy link
Owner

AlexxIT commented Jun 12, 2023

@AlexxIT AlexxIT closed this as completed Jun 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

4 participants