cannot import name 'ModelMetaclass' from 'pydantic.main' #13350
-
Since I upgraded pydantic to the latest release I'm unable to import spacy (also the latest release) because I get this exception:
I see that pydantic has moved ModelMetaclass (and claims it's private and should not be used) but evidently spacy is using it (in its original location). Is there a recommended workaround? I can't downgrade pydantic because another module has a dependency on the 2.0 releases. |
Beta Was this translation helpful? Give feedback.
Replies: 9 comments 2 replies
-
I was able to hack a copy of ModelMetaclass like this:
but then I ran into a missing |
Beta Was this translation helpful? Give feedback.
-
As it stands, unless I'm missing something, I think I'm unable to use spaCy in this project (due to my existing dependency on pydantic V2), but that seems a bit mad, so hopefully there's a workaround! |
Beta Was this translation helpful? Give feedback.
-
Hi @maspotts, thanks for the report! Which exact versions of spaCy and Pydantic are you using? We'll look into this. |
Beta Was this translation helpful? Give feedback.
-
I can't reproduce this - with the latest versions of |
Beta Was this translation helpful? Give feedback.
-
That's awesome news: thanks! Here's what I get:
|
Beta Was this translation helpful? Give feedback.
-
Here's the same with spacy 3.7.4:
|
Beta Was this translation helpful? Give feedback.
-
I'm on a Mac Studio (M1 Max) running Sonoma 14.2.1. |
Beta Was this translation helpful? Give feedback.
-
Thanks for those detailed logs! That's helpful. First - definitely don't install spacy 4.0.0.devX yet - it's not ready ;-) When you install spaCy 3.7.4, somehow your environment is not installing the latest
The latest is 0.1.4 and has compatibility for Pydantic v2 (since 0.1.1). Try upgrading that (and probably also Thinc)? |
Beta Was this translation helpful? Give feedback.
-
Ah! That did it! Upgraded confection==0.1.4 and I can import spacy 3.7.4 with pydantic 2.6.1!! Thanks so much!!! I wonder why confection was being left at 0.0.4. I sometimes feel like pip just crosses its fingers and gives up when it tries to resolve dependencies! |
Beta Was this translation helpful? Give feedback.
Thanks for those detailed logs! That's helpful.
First - definitely don't install spacy 4.0.0.devX yet - it's not ready ;-)
When you install spaCy 3.7.4, somehow your environment is not installing the latest
confection
:The latest is 0.1.4 and has compatibility for Pydantic v2 (since 0.1.1). Try upgrading that (and probably also Thinc)?