I am engaging in unsupported behaviour - using my system spacy instead of a venv. This issue is just to have a record of the problem and the solution, as I had it before but forgot what caused it.
Sometimes spacy gets broken becuase of issues with the python packages pydantic and typing_extensions. You'll see an error like the following:
Anki 23.12.1 (29f9f0dc) (src) (ao)
Python 3.11.6 Qt 6.6.1 PyQt 6.6.1
Platform: Linux-6.7.1-arch1-1-x86_64-with-glibc2.38
Traceback (most recent call last):
File "/usr/lib/python3.11/site-packages/aqt/__init__.py", line 136, in open
instance = creator(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/hearth/.local/share/Anki2/addons21/472573498/settings_dialog.py", line 77, in __init__
self._morphemizers = get_all_morphemizers()
^^^^^^^^^^^^^^^^^^^^^^
File "/home/hearth/.local/share/Anki2/addons21/472573498/morphemizer.py", line 58, in get_all_morphemizers
for spacy_model in spacy_wrapper.get_installed_models():
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/hearth/.local/share/Anki2/addons21/472573498/spacy_wrapper.py", line 351, in get_installed_models
import spacy.util # pylint:disable=import-outside-toplevel
^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.11/site-packages/spacy/__init__.py", line 6, in <module>
from .errors import setup_default_warnings
File "/usr/lib/python3.11/site-packages/spacy/errors.py", line 3, in <module>
from .compat import Literal
File "/usr/lib/python3.11/site-packages/spacy/compat.py", line 4, in <module>
from thinc.util import copy_array
File "/usr/lib/python3.11/site-packages/thinc/__init__.py", line 5, in <module>
from .config import registry
File "/usr/lib/python3.11/site-packages/thinc/config.py", line 2, in <module>
import confection
File "/usr/lib/python3.11/site-packages/confection/__init__.py", line 11, in <module>
from pydantic.main import ModelMetaclass
ImportError: cannot import name 'ModelMetaclass' from 'pydantic.main' (/usr/lib/python3.11/site-packages/pydantic/main.py)
This happens because of version mismatches with the packages python-spacy, python-pydantic, and python-typing_extensions. Note that the latter are in the extra repository, whereas spacy is an AUR package. As of this time, the extra repository has pydantic 2.5.3-1, whereas spacy requests 1.10.14.
I may eventually write an AUR package that takes care of this whole thing, but until then, the lowest effort solution for most users is of course to just use the venv as advised. (Surprise!)
Hello,
I am engaging in unsupported behaviour - using my system spacy instead of a venv. This issue is just to have a record of the problem and the solution, as I had it before but forgot what caused it.
Sometimes spacy gets broken becuase of issues with the python packages
pydantic
andtyping_extensions
. You'll see an error like the following:This happens because of version mismatches with the packages
python-spacy
,python-pydantic
, andpython-typing_extensions
. Note that the latter are in theextra
repository, whereas spacy is an AUR package. As of this time, theextra
repository has pydantic 2.5.3-1, whereas spacy requests 1.10.14.I may eventually write an AUR package that takes care of this whole thing, but until then, the lowest effort solution for most users is of course to just use the venv as advised. (Surprise!)