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

NameError: name '_GenericAlias' is not defined when importing pydantic #3145

Closed
3 tasks done
eykamp opened this issue Aug 30, 2021 · 3 comments
Closed
3 tasks done

NameError: name '_GenericAlias' is not defined when importing pydantic #3145

eykamp opened this issue Aug 30, 2021 · 3 comments
Labels
bug V1 Bug related to Pydantic V1.X

Comments

@eykamp
Copy link

eykamp commented Aug 30, 2021

Checks

  • I added a descriptive title to this issue
  • I have searched (google, github) for similar issues and couldn't find anything
  • I have read and followed the docs and still think this is a bug

Bug

It's pretty obvious I've done something stupid, but I can't even get pydantic to import.

If I downgrade to 1.7, it works, but 1.8 does not.

Code:

import pydantic

Error:

>>> import pydantic
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/plastic/.local/lib/python3.10/site-packages/pydantic/__init__.py", line 2, in <module>
    from . import dataclasses
  File "/home/plastic/.local/lib/python3.10/site-packages/pydantic/dataclasses.py", line 3, in <module>
    from .class_validators import gather_all_validators
  File "/home/plastic/.local/lib/python3.10/site-packages/pydantic/class_validators.py", line 8, in <module>
    from .errors import ConfigError
  File "/home/plastic/.local/lib/python3.10/site-packages/pydantic/errors.py", line 5, in <module>
    from .typing import display_as_type
  File "/home/plastic/.local/lib/python3.10/site-packages/pydantic/typing.py", line 23, in <module>
    from typing_extensions import Annotated, Literal
  File "/home/plastic/.local/lib/python3.10/site-packages/typing_extensions.py", line 2390, in <module>
    class _ConcatenateGenericAlias(list):
  File "/home/plastic/.local/lib/python3.10/site-packages/typing_extensions.py", line 2394, in _ConcatenateGenericAlias
    __class__ = _GenericAlias
NameError: name '_GenericAlias' is not defined
>>>

Output of python -c "import pydantic.utils; print(pydantic.utils.version_info())":

Same error as above (perhaps unsurprisingly)

Versions:

~$ python3 --version
Python 3.10.0a3
~$ pip freeze | grep pydantic
pydantic==1.8.2
~$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 16.04.7 LTS
Release:        16.04
Codename:       xenial
~$
@eykamp eykamp added the bug V1 Bug related to Pydantic V1.X label Aug 30, 2021
@iamthen0ise
Copy link

Hi!

It is a general issue in typing module. i think it should be resolved as far as this issue will be marked as fixed python/typing#865

@domdfcoding
Copy link

As a quick workaround downgrading typing-extensions to 3.10.0.0 or earlier should work.

python3 -m pip install typing-extensions==3.10.0.0

@PrettyWood
Copy link
Member

Thanks people for answering! 🙏 Not an issue with pydantic

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug V1 Bug related to Pydantic V1.X
Projects
None yet
Development

No branches or pull requests

4 participants