pymorphy2 icon indicating copy to clipboard operation
pymorphy2 copied to clipboard

Не работает с Python 3.11

Open PalmtopTiger opened this issue 3 years ago • 6 comments

Из-за удаления метода inspect.getargspec. Нужно заменить вызов на getfullargspec. Решение тут: #157

PalmtopTiger avatar Oct 25 '22 12:10 PalmtopTiger

analyzer = MorphAnalyzer(lang="uk")
           ^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.11/site-packages/pymorphy2/analyzer.py", line 224, in __init__
  self._init_units(units)
File "/usr/lib/python3.11/site-packages/pymorphy2/analyzer.py", line 235, in _init_units
  self._units.append((self._bound_unit(unit), False))
                      ^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.11/site-packages/pymorphy2/analyzer.py", line 246, in _bound_unit
  unit = unit.clone()
         ^^^^^^^^^^^^
File "/usr/lib/python3.11/site-packages/pymorphy2/units/base.py", line 35, in clone
  return self.__class__(**self._get_params())
                          ^^^^^^^^^^^^^^^^^^
File "/usr/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 "/usr/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'. Did you mean: 'getargs'?

doctorcolossus avatar May 17 '23 17:05 doctorcolossus

https://github.com/pymorphy2/pymorphy2/pull/162

doctorcolossus avatar May 17 '23 17:05 doctorcolossus

Многоуважаемые люди из интернета сделали форк, который пока что работает как временное решение: https://github.com/no-plagiarism/pymorphy3

mrmeloman avatar May 23 '23 13:05 mrmeloman

There is also https://github.com/pymorphy2-fork, they have an updated version of the underlying DAWG library, so that you can use the "fast" extra on newer Pythons.

Vuizur avatar Sep 03 '23 11:09 Vuizur

https://github.com/pymorphy2/pymorphy2/pull/173

patch /usr/lib/python3.12/site-packages/pymorphy2/units/base.py < patch

--- /usr/lib/python3.12/site-packages/pymorphy2/units/base.py	2024-06-11 00:25:00.495794626 +0300
+++ /usr/lib/python3.11/site-packages/pymorphy2/units/base.py	2023-05-17 20:07:20.322965962 +0300
@@ -67,7 +67,7 @@
         """
         if cls.__init__ is object.__init__:
             return []
-        args, varargs, kw, default = inspect.getargspec(cls.__init__)
+        args, *_ = inspect.getfullargspec(cls.__init__)
         return sorted(args[1:])

     def _get_params(self):

doctorcolossus avatar Jun 10 '24 21:06 doctorcolossus

@doctorcolossus actually, you've already posted your solution here, but the pull request for the issue exists for a long time, it is #161. A lot of similar pull requests don't fix the main problem: the project is abandoned.

insolor avatar Jun 10 '24 22:06 insolor