I have code that worked fine with Python 3.10.12 and Pydantic 2.7.3.
I read that Pydantic ^2.8 supports Python 3.13.
The same code, and indeed even just import pydantic
under a Python 3.13.0 shell with Pydantic 2.10.2, however, gives:
File "/home/user/path-to-package/src/validator.py", line 9, in <module>
from pydantic import TypeAdapter, BaseModel, validator
File "/home/user/path-to-package/.venv/lib/python3.13/site-packages/pydantic/__init__.py", line 396, in <module>
_getattr_migration = getattr_migration(__name__)
File "/home/user/path-to-package/.venv/lib/python3.13/site-packages/pydantic/_migration.py", line 260, in getattr_migration
from .errors import PydanticImportError
File "/home/user/path-to-package/.venv/lib/python3.13/site-packages/pydantic/errors.py", line 7, in <module>
from typing_extensions import Literal, Self
ModuleNotFoundError: No module named 'typing_extensions'
Why?
How can I fix this?
ModuleNotFoundError: No module named 'typing_extensions'
You possess two Python versions which are 3.10.12 and 3.13. The typing_extensions
will only be available for download in version 3.10, not 3.13.
The problem can be fixed.
Add Python 3.13 version.
py -3.13 -m pip install typing-extensions --upgrade
As for me, I have Python 3.12.7 and 3.14.0a2.
I tried this today py -3.14 -m pip install typing-extensions --upgrade
And here is output:
> C:\Users\>py -3.14 -m pip install typing-extensions --upgrade
> Collecting typing-extensions Using cached
> typing_extensions-4.12.2-py3-none-any.whl.metadata (3.0 kB) Using
> cached typing_extensions-4.12.2-py3-none-any.whl (37 kB) Installing
> collected packages: typing-extensions Successfully installed
> typing-extensions-4.12.2