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

TypeError: dataclass_transform() got an unexpected keyword argument 'field_specifiers' #12034

Closed
albertvillanova opened this issue Dec 30, 2022 · 9 comments · Fixed by #12036
Closed
Labels
install Installation issues third-party Third-party packages and services

Comments

@albertvillanova
Copy link
Contributor

albertvillanova commented Dec 30, 2022

After latest pydantic-1.10.3 release, spacy no longer can be imported, raising a TypeError.

The root cause is an incompatibility between pydantic-1.10.3 and your requirement typing_extensions>=3.7.4,<4.2.0; python_version < "3.8".

See issue in pydantic:

See fixing PR in pydantic (typing-extensions>=4.2.0), which will be incompatible with your requirement typing_extensions>=3.7.4,<4.2.0; python_version < "3.8":

To reproduce the error:

pip install spacy
python -c "import spacy"

raises:

Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File ".../venvs/venv-py37-spacy/lib/python3.7/site-packages/spacy/__init__.py", line 6, in <module>
    from .errors import setup_default_warnings
  File ".../venvs/venv-py37-spacy/lib/python3.7/site-packages/spacy/errors.py", line 2, in <module>
    from .compat import Literal
  File ".../venvs/venv-py37-spacy/lib/python3.7/site-packages/spacy/compat.py", line 3, in <module>
    from thinc.util import copy_array
  File ".../venvs/venv-py37-spacy/lib/python3.7/site-packages/thinc/__init__.py", line 5, in <module>
    from .config import registry
  File ".../venvs/venv-py37-spacy/lib/python3.7/site-packages/thinc/config.py", line 2, in <module>
    import confection
  File ".../venvs/venv-py37-spacy/lib/python3.7/site-packages/confection/__init__.py", line 10, in <module>
    from pydantic import BaseModel, create_model, ValidationError, Extra
  File "pydantic/__init__.py", line 2, in init pydantic.__init__
  File "pydantic/dataclasses.py", line 46, in init pydantic.dataclasses
    # | None    | Attribute is set to None.               |
  File "pydantic/main.py", line 121, in init pydantic.main
TypeError: dataclass_transform() got an unexpected keyword argument 'field_specifiers'

Your Environment

  • Operating System:
  • Python Version Used: 3.7.15
  • spaCy Version Used: 3.4.4
  • Environment Information:
@adrianeboyd
Copy link
Contributor

Thanks for the report! pydantic v1.10.3 has been yanked as a temporary workaround for this problem until our packages can be updated.

@muhammadsmalik
Copy link

muhammadsmalik commented Dec 30, 2022

Is there a workaround to this issue? Or do I need to wait for an update or something? Because I am still not able to install any spacy models

@adrianeboyd
Copy link
Contributor

If you install spacy in a new venv, it should work again for python 3.7 with no additional steps.

To fix an existing python 3.7 venv, you can downgrade to pydantic==1.10.2.

For spacy, this issue should only affect python 3.7 installs.

@muhammadsmalik
Copy link

Oh thanks a lot for the swift reply Adriane. Really appreciate it!

@MFatnassi
Copy link

I am still not able to install spacy in Databricks with:
Python 3.9.5
There are any solution to solve the issue?

@adrianeboyd
Copy link
Contributor

For python 3.9 I'm not sure what's going on, we'd need more information about how you're installing spacy and what errors you're seeing.

As a first step, you can run pip check to see if there are any conflicting packages in your environment.

If that doesn't point to anything, can you share the exact install command you're using and pip freeze from your environment? The main things are the installed versions of spacy, pydantic, and typing_extensions, and whether you have requirements other than spacy that are affecting the versions that are installed in the end.

@pascalbovy
Copy link

Hi, I'm experiencing similar issues. My spacy environment worked flawlessly until I installed the dataframe_image package in the same envs. No I'm getting the same error:

TypeError: dataclass_transform() got an unexpected keyword argument 'field_specifiers'

I've uninstalled the dataframe_image package, but the problem persists.

@polm
Copy link
Contributor

polm commented Feb 2, 2023

In #12200 a user resolved the issue by uninstalling and then re-installing spaCy, have you tried that?

If that doesn't fix it, please let us know the relevant versions of everything, like Python, spaCy, pydantic, etc.

@github-actions
Copy link
Contributor

github-actions bot commented Mar 5, 2023

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.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 5, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
install Installation issues third-party Third-party packages and services
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants