Skip to content

bug: pydantic v1 incompatability error (Py3.14 wheels) #13895

Closed

Description

@chamalgomes

Noticed the following error on the CI runs, might be due to pydantic incompatibility ?

How to reproduce the behaviour

from spacy.language import Language

Traceback

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
    from spacy.language import Language
  File "/workspaces/test.venv/lib/python3.14/site-packages/spacy/__init__.py", line 13, in <module>
    from . import pipeline  # noqa: F401
    ^^^^^^^^^^^^^^^^^^^^^^
  File "/workspaces/test.venv/lib/python3.14/site-packages/spacy/pipeline/__init__.py", line 1, in <module>
    from .attributeruler import AttributeRuler
  File "/workspaces/test/.venv/lib/python3.14/site-packages/spacy/pipeline/attributeruler.py", line 10, in <module>
    from ..language import Language
  File "/workspaces/test/.venv/lib/python3.14/site-packages/spacy/language.py", line 46, in <module>
    from .pipe_analysis import analyze_pipes, print_pipe_analysis, validate_attrs
  File "/workspaces/test/.venv/lib/python3.14/site-packages/spacy/pipe_analysis.py", line 6, in <module>
    from .tokens import Doc, Span, Token
  File "/workspaces/test/.venv/lib/python3.14/site-packages/spacy/tokens/__init__.py", line 1, in <module>
    from ._serialize import DocBin
  File "/workspaces/test/.venv/lib/python3.14/site-packages/spacy/tokens/_serialize.py", line 14, in <module>
    from ..vocab import Vocab
  File "spacy/vocab.pyx", line 1, in init spacy.vocab
  File "spacy/tokens/doc.pyx", line 49, in init spacy.tokens.doc
  File "/workspaces/test/.venv/lib/python3.14/site-packages/spacy/schemas.py", line 195, in <module>
    class TokenPatternString(BaseModel):
    ...<43 lines>...
            return v
  File "/workspaces/test/.venv/lib/python3.14/site-packages/pydantic/v1/main.py", line 221, in __new__
    inferred = ModelField.infer(
        name=var_name,
    ...<3 lines>...
        config=config,
    )
  File "/workspaces/test/.venv/lib/python3.14/site-packages/pydantic/v1/fields.py", line 504, in infer
    return cls(
        name=name,
    ...<7 lines>...
        field_info=field_info,
    )
  File "/workspaces/test/.venv/lib/python3.14/site-packages/pydantic/v1/fields.py", line 434, in __init__
    self.prepare()
    ~~~~~~~~~~~~^^
  File "/workspaces/test/.venv/lib/python3.14/site-packages/pydantic/v1/fields.py", line 544, in prepare
    self._set_default_and_type()
    ~~~~~~~~~~~~~~~~~~~~~~~~~~^^
  File "/workspaces/test/.venv/lib/python3.14/site-packages/pydantic/v1/fields.py", line 576, in _set_default_and_type
    raise errors_.ConfigError(f'unable to infer type for attribute "{self.name}"')
pydantic.v1.errors.ConfigError: unable to infer type for attribute "REGEX"

Your Environment

  • Operating System: ubuntu-latest
  • Python Version Used: 3.14
  • spaCy Version Used: 3.8.10

Activity

  1. korobovsp commented on Nov 18, 2025

    @korobovsp

    C:\Users\bal1web\AppData\Local\Programs\Python\Python314\Lib\site-packages\confection_init_.py:38: UserWarning: Core Pydantic V1 functionality isn't compatible with Python 3.14 or greater.
    from pydantic.v1 import BaseModel, Extra, ValidationError, create_model
    Traceback (most recent call last):
    File "C:\bal1web\sintax.py", line 2, in
    import spacy
    File "C:\Users\bal1web\AppData\Local\Programs\Python\Python314\Lib\site-packages\spacy_init_.py", line 13, in
    from . import pipeline # noqa: F401
    ^^^^^^^^^^^^^^^^^^^^^^
    File "C:\Users\bal1web\AppData\Local\Programs\Python\Python314\Lib\site-packages\spacy\pipeline_init_.py", line 1, in
    from .attributeruler import AttributeRuler
    File "C:\Users\bal1web\AppData\Local\Programs\Python\Python314\Lib\site-packages\spacy\pipeline\attributeruler.py", line 10, in
    from ..language import Language
    File "C:\Users\bal1web\AppData\Local\Programs\Python\Python314\Lib\site-packages\spacy\language.py", line 46, in
    from .pipe_analysis import analyze_pipes, print_pipe_analysis, validate_attrs
    File "C:\Users\bal1web\AppData\Local\Programs\Python\Python314\Lib\site-packages\spacy\pipe_analysis.py", line 6, in
    from .tokens import Doc, Span, Token
    File "C:\Users\bal1web\AppData\Local\Programs\Python\Python314\Lib\site-packages\spacy\tokens_init_.py", line 1, in
    from ._serialize import DocBin
    File "C:\Users\bal1web\AppData\Local\Programs\Python\Python314\Lib\site-packages\spacy\tokens_serialize.py", line 14, in
    from ..vocab import Vocab
    File "spacy/vocab.pyx", line 1, in init spacy.vocab
    File "spacy/tokens/doc.pyx", line 49, in init spacy.tokens.doc
    File "C:\Users\bal1web\AppData\Local\Programs\Python\Python314\Lib\site-packages\spacy\schemas.py", line 195, in
    class TokenPatternString(BaseModel):
    ...<43 lines>...
    return v
    File "C:\Users\bal1web\AppData\Local\Programs\Python\Python314\Lib\site-packages\pydantic\v1\main.py", line 221, in new
    inferred = ModelField.infer(
    name=var_name,
    ...<3 lines>...
    config=config,
    )
    File "C:\Users\bal1web\AppData\Local\Programs\Python\Python314\Lib\site-packages\pydantic\v1\fields.py", line 504, in infer
    return cls(
    name=name,
    ...<7 lines>...
    field_info=field_info,
    )
    File "C:\Users\bal1web\AppData\Local\Programs\Python\Python314\Lib\site-packages\pydantic\v1\fields.py", line 434, in init
    self.prepare()
    ~~~~~~~~~~~~^^
    File "C:\Users\bal1web\AppData\Local\Programs\Python\Python314\Lib\site-packages\pydantic\v1\fields.py", line 544, in prepare
    self._set_default_and_type()
    ~~~~~~~~~~~~~~~~~~~~~~~~~~^^
    File "C:\Users\bal1web\AppData\Local\Programs\Python\Python314\Lib\site-packages\pydantic\v1\fields.py", line 576, in set_default_and_type
    raise errors
    .ConfigError(f'unable to infer type for attribute "{self.name}"')
    pydantic.v1.errors.ConfigError: unable to infer type for attribute "REGEX"

  2. changed the title [-]bug: pydantic v1 incompatability[/-] [+]bug: pydantic v1 incompatability error (Py3.14 wheels)[/+] on Nov 24, 2025
  3. ghmeier commented on Nov 26, 2025

    @ghmeier

    Hey, just want to add on here that spacy isn't functional on Python 3.14 because of this issue. There's a more detailed synopsis here: pydantic/pydantic#12363, but the pydantic.v1 namespace on pydantic>=2.0.0 doesn't support Python 3.14. Similarly, pydantic<2.0.0 doesn't support Python 3.14 at all.

  4. ghmeier commented on Dec 20, 2025

    @ghmeier

    For folks following along, Pydantic merged an update to v1 that supports 3.14: pydantic/pydantic#12636. That version of v1 should be included in pydantic v2.13 when that's released in a few weeks.

  5. bvolkmer commented on Jan 5, 2026

    @bvolkmer

    Wouldn't this be the moment to seriously consider upgrading to Pydantic v2? As v1 will cease to be supported eventually. For 3.14 it already wasn't planned (even though it was now implemented, but with the v2 release still pending)

  6. chamalgomes commented on Feb 23, 2026

    @chamalgomes
    Author

    @ghmeier latest Pydantic pre-release has a minor issue with version but the code is the latest and it still does not resolve the above issue. pydantic/pydantic#12852

  7. ghmeier commented on Mar 19, 2026

    @ghmeier

    Dang, I think they still haven't released the new minor version outside the beta... I'd still be open to pushing my open PRs to resolve this issue more holistically:

    Just need some input from the maintainers unfortunately.

  8. honnibal commented on Mar 20, 2026

    @honnibal
    Member

    Sorry about this. Working on it.

  9. honnibal commented on Mar 20, 2026

    @honnibal
    Member

    Okay confection v1 and new weasel are up. I'll try an updated build in spaCy now.

  10. honnibal commented on Mar 23, 2026

    @honnibal
    Member

    Python 3.14 and Pydantic v2 support now finally up

  11. dwvisser commented on Mar 23, 2026

    @dwvisser
    from spacy.language import Language

    still generates a Traceback on spacy 3.8.12 in Python 3.14:

    /tmp/tmp.azSvnH1Vsh/lib/python3.14/site-packages/confection/__init__.py:38: UserWarning: Core Pydantic V1 functionality isn't compatible with Python 3.14 or greater.
      from pydantic.v1 import BaseModel, Extra, ValidationError, create_model
    Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
        from spacy.language import Language
      File "/tmp/tmp.azSvnH1Vsh/lib/python3.14/site-packages/spacy/__init__.py", line 16, in <module>
        from .cli.info import info  # noqa: F401
        ^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "/tmp/tmp.azSvnH1Vsh/lib/python3.14/site-packages/spacy/cli/__init__.py", line 4, in <module>
        from . import download as download_module  # noqa: F401
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "/tmp/tmp.azSvnH1Vsh/lib/python3.14/site-packages/spacy/cli/download.py", line 20, in <module>
        from ._util import SDIST_SUFFIX, WHEEL_SUFFIX, Arg, Opt, app
      File "/tmp/tmp.azSvnH1Vsh/lib/python3.14/site-packages/spacy/cli/_util.py", line 28, in <module>
        from weasel import app as project_cli
      File "/tmp/tmp.azSvnH1Vsh/lib/python3.14/site-packages/weasel/__init__.py", line 1, in <module>
        from .cli import app
      File "/tmp/tmp.azSvnH1Vsh/lib/python3.14/site-packages/weasel/cli/__init__.py", line 3, in <module>
        from .assets import project_assets
      File "/tmp/tmp.azSvnH1Vsh/lib/python3.14/site-packages/weasel/cli/assets.py", line 11, in <module>
        from ..util import SimpleFrozenDict, download_file, ensure_path, get_checksum
      File "/tmp/tmp.azSvnH1Vsh/lib/python3.14/site-packages/weasel/util/__init__.py", line 2, in <module>
        from .config import load_project_config, parse_config_overrides
      File "/tmp/tmp.azSvnH1Vsh/lib/python3.14/site-packages/weasel/util/config.py", line 13, in <module>
        from ..schemas import ProjectConfigSchema, validate
      File "/tmp/tmp.azSvnH1Vsh/lib/python3.14/site-packages/weasel/schemas.py", line 34, in <module>
        class ProjectConfigAssetGitItem(BaseModel):
        ...<3 lines>...
            branch: StrictStr = Field("master", title="Branch to clone from")
      File "/tmp/tmp.azSvnH1Vsh/lib/python3.14/site-packages/pydantic/v1/main.py", line 221, in __new__
        inferred = ModelField.infer(
            name=var_name,
        ...<3 lines>...
            config=config,
        )
      File "/tmp/tmp.azSvnH1Vsh/lib/python3.14/site-packages/pydantic/v1/fields.py", line 504, in infer
        return cls(
            name=name,
        ...<7 lines>...
            field_info=field_info,
        )
      File "/tmp/tmp.azSvnH1Vsh/lib/python3.14/site-packages/pydantic/v1/fields.py", line 434, in __init__
        self.prepare()
        ~~~~~~~~~~~~^^
      File "/tmp/tmp.azSvnH1Vsh/lib/python3.14/site-packages/pydantic/v1/fields.py", line 544, in prepare
        self._set_default_and_type()
        ~~~~~~~~~~~~~~~~~~~~~~~~~~^^
      File "/tmp/tmp.azSvnH1Vsh/lib/python3.14/site-packages/pydantic/v1/fields.py", line 576, in _set_default_and_type
        raise errors_.ConfigError(f'unable to infer type for attribute "{self.name}"')
    pydantic.v1.errors.ConfigError: unable to infer type for attribute "repo"
  12. jonbuffington commented on Mar 23, 2026

    @jonbuffington

    @honnibal Thanks for making the changes! In addition to @dwvisser 's report, spacy v3.18.12 no longer works when using pydantic v2.13.0b2 and the model, en_core_web_md:

      File "/tmp/py/webpages/augmentor/prediction.py", line 22, in <module>
        from text.nlp import nlp
      File "/tmp/py/text/nlp.py", line 7, in <module>
        nlp = spacy.load("en_core_web_md")
      File "/tmp/py/.venv/lib/python3.14/site-packages/spacy/__init__.py", line 52, in load
        return util.load_model(
               ~~~~~~~~~~~~~~~^
            name,
            ^^^^^
        ...<4 lines>...
            config=config,
            ^^^^^^^^^^^^^^
        )
        ^
      File "/tmp/py/.venv/lib/python3.14/site-packages/spacy/util.py", line 524, in load_model
        return load_model_from_package(name, **kwargs)  # type: ignore[arg-type]
      File "/tmp/py/.venv/lib/python3.14/site-packages/spacy/util.py", line 560, in load_model_from_package
        return cls.load(vocab=vocab, disable=disable, enable=enable, exclude=exclude, config=config)  # type: ignore[attr-defined]
               ~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "/tmp/py/.venv/lib/python3.14/site-packages/en_core_web_md/__init__.py", line 10, in load
        return load_model_from_init_py(__file__, **overrides)
      File "/tmp/py/.venv/lib/python3.14/site-packages/spacy/util.py", line 741, in load_model_from_init_py
        return load_model_from_path(
            data_path,
        ...<5 lines>...
            config=config,
        )
      File "/tmp/py/.venv/lib/python3.14/site-packages/spacy/util.py", line 598, in load_model_from_path
        nlp = load_model_from_config(
            config,
        ...<4 lines>...
            meta=meta,
        )
      File "/tmp/py/.venv/lib/python3.14/site-packages/spacy/util.py", line 646, in load_model_from_config
        nlp = lang_cls.from_config(
            config,
        ...<6 lines>...
            meta=meta,
        )
      File "/tmp/py/.venv/lib/python3.14/site-packages/spacy/language.py", line 1832, in from_config
        resolved_nlp = registry.resolve(
            filled["nlp"], validate=validate, schema=ConfigSchemaNlp
        )
      File "/tmp/py/.venv/lib/python3.14/site-packages/confection/__init__.py", line 760, in resolve
        resolved, _ = cls._make(
                      ~~~~~~~~~^
            config, schema=schema, overrides=overrides, validate=validate, resolve=True
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        )
        ^
      File "/tmp/py/.venv/lib/python3.14/site-packages/confection/__init__.py", line 809, in _make
        filled, _, resolved = cls._fill(
                              ~~~~~~~~~^
            config, schema, validate=validate, overrides=overrides, resolve=resolve
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        )
        ^
      File "/tmp/py/.venv/lib/python3.14/site-packages/confection/__init__.py", line 937, in _fill
        result = schema.parse_obj(validation)
      File "/tmp/py/.venv/lib/python3.14/site-packages/pydantic/main.py", line 1390, in parse_obj
        return cls.model_validate(obj)
               ~~~~~~~~~~~~~~~~~~^^^^^
      File "/tmp/py/.venv/lib/python3.14/site-packages/pydantic/main.py", line 736, in model_validate
        return cls.__pydantic_validator__.validate_python(
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "/tmp/py/.venv/lib/python3.14/site-packages/pydantic/_internal/_mock_val_ser.py", line 100, in __getattr__
        raise PydanticUserError(self._error_message, code=self._code)
    pydantic.errors.PydanticUserError: `ConfigSchemaNlp` is not fully defined; you should define `Language`, then call `ConfigSchemaNlp.model_rebuild()`.
    
    For further information visit https://errors.pydantic.dev/2.13/u/class-not-fully-defined
    
  13. dwvisser commented on Mar 23, 2026

    @dwvisser

    I found that both uv pip install and regular pip install were installing an old version of weasel (0.4.3) for some reason. When I manually did uv pip install "weasel>=1.0", the problem resolved.

  14. jonbuffington commented on Mar 23, 2026

    @jonbuffington

    @dwvisser The package metadata has weasel>=0.4.2,<0.5.0 although spacy's master branch requirements.txt has weasel>=1.0.0,<2.0.0.

    E.g., uv's output:

    …
      ╰─▶ Because only spacy<=3.8.12 is available and spacy==3.8.12 depends on weasel>=0.4.2,<0.5.0, we can conclude that
          spacy>=3.8.12 depends on weasel>=0.4.2,<0.5.0.
    …
    
  15. dwvisser commented on Mar 23, 2026

    @dwvisser

    @dwvisser The package metadata has weasel>=0.4.2,<0.5.0 although spacy' master branch requirements.txt has weasel>=1.0.0,<2.0.0.

    Yup. I see that too:

    ❯ python -c "from importlib.metadata import metadata; print(metadata('spacy'))" | grep weasel
    Requires-Dist: weasel<0.5.0,>=0.4.2
  16. honnibal commented on Mar 23, 2026

    @honnibal
    Member

    That's odd, the setup.cfg has weasel 1.0 too. Let me figure out where I messed this up, sorry

  17. honnibal commented on Mar 23, 2026

    @honnibal
    Member

    The correct version is 3.8.13, did you update? I yanked the 3.8.12 release shortly after publishing it. I'm seeing the right meta here:

    ⎿  Name: spacy
    Version: 3.8.13
    Requires-Dist: spacy-legacy<3.1.0,>=3.0.11
    Requires-Dist: spacy-loggers<2.0.0,>=1.0.0
    Requires-Dist: murmurhash<1.1.0,>=0.28.0
    Requires-Dist: cymem<2.1.0,>=2.0.2
    Requires-Dist: preshed<3.1.0,>=3.0.2
    Requires-Dist: thinc<8.4.0,>=8.3.12
    Requires-Dist: wasabi<1.2.0,>=0.9.1
    Requires-Dist: srsly<3.0.0,>=2.5.3
    Requires-Dist: catalogue<2.1.0,>=2.0.6
    Requires-Dist: weasel<2.0.0,>=1.0.0
    Requires-Dist: confection<2.0.0,>=1.3.2
    Requires-Dist: typer<1.0.0,>=0.3.0
    Requires-Dist: tqdm<5.0.0,>=4.38.0
    Requires-Dist: numpy>=1.15.0; python_version < "3.9"
    Requires-Dist: numpy>=1.19.0; python_version >= "3.9"
    Requires-Dist: requests<3.0.0,>=2.13.0
    Requires-Dist: pydantic<3.0.0,>=2.0.0

  18. jonbuffington commented on Mar 23, 2026

    @jonbuffington

    @honnibal I was trying 3.8.12 as 3.8.13 was not available to me yet. 3.8.13 does work for me as I just tried it. Thanks again!

  19. github-actions commented on Apr 23, 2026

    @github-actions
    Contributor

    This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

  20. locked as resolved and limited conversation to collaborators on Apr 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions