Hello I am using Python 3.8
And I am trying to create a function to sort and print a list in the form of,
{first_element}, {second_element} and {last_element}
I've used the inflect library in Python to do this because it is expected to be used in my assignment.
import inflect
p = inflect.engine()
def sort():
fruits = ["apple", "banana", "carrot"]
mylist = p.join(fruits)
print(mylist)
sort()
But when I execute this I get the following error:
Traceback (most recent call last):
File "main.py", line 1, in <module>
import inflect
File "/home/username/.local/lib/python3.8/site-packages/inflect/__init__.py", line 77, in <module>
from pydantic.typing import Annotated
ImportError: cannot import name 'Annotated' from 'pydantic.typing' (/home/username/.local/lib/python3.8/site-packages/pydantic/typing.py)
I tried reinstalling the library called Pydantic. But it didn't change anything.
Pydantic 2.0 was released a few hours ago which has introduced breaking changes for inflect
.
Ideally, inflect should have had an upper max for pydantic
version in their project. Track the issue on inflect here.
Check what version of pydantic
is installed on your machine. It must be 2.0
. You need to uninstall
that and install
the highest 1.xx.x
.
I understand this answer will be obsolete once this issue resolves, but here are the only two things to do when such breaking changes are encountered:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With