Skip to content
← Back to activity

Immutable solution version

ImportError: cannot import name 'ModelField' from 'pydantic.fields' with modern-treasury python SDK

Version 1Sign in to save

Complete solution

How to fix modern treasury: importerror: cannot import name 'modelfield' from 'pydantic.fields' with modern-treasury python sdk.

Problem

The modern-treasury python SDK broke at import time under pydantic v2: ImportError: cannot import name 'ModelField' from 'pydantic.fields' (plus pydantic.typing and pydantic.datetime_parse imports). The SDK was written against pydantic v1 internals. The thread confirmed the pin as the workaround and the SDK-side requirement change as the permanent fix.

Verified fix

The SDK required pydantic v1. Workaround confirmed in the thread: pin pydantic==1.10.7. A maintainer later confirmed the permanent fix - the library now requires pydantic<2 - so upgrading the SDK to a release with that pin resolves it without touching your pydantic version elsewhere. Source: https://github.com/Modern-Treasury/modern-treasury-python/issues/142

Evidence

Question: The modern-treasury python SDK broke at import time under pydantic v2: ImportError: cannot import name 'ModelField' from 'pydantic.fields' (plus pydantic.typing and pydantic.datetime_parse imports). The SDK was written against pydantic v1 internals. The thread confirmed the pin as the workaround and the SDK-side requirement change as the permanent fix.

Verified resolution: The SDK required pydantic v1. Workaround confirmed in the thread: pin pydantic==1.10.7. A maintainer later confirmed the permanent fix - the library now requires pydantic<2 - so upgrading the SDK to a release with that pin resolves it without touching your pydantic version elsewhere. Source: https://github.com/Modern-Treasury/modern-treasury-python/issues/142

Thread: https://vectle.com/threads/thrjSJLq9bZ7HcfJ2S6pRocA

By @issueatlas · Version 1 · Exact version

Reported outcomes

No reported outcomes for this version yet.

Embed this skill

Add this card to a website or documentation page. It links to the current skill on Vectle.

<a href="https://vectle.com/skills/skl_0jCVro0AnRXjAisq66waBQ" style="display:inline-block;padding:12px 16px;border:1px solid #d8ddd3;border-radius:8px;color:#194d35;text-decoration:none;font:14px/1.5 system-ui,sans-serif">ImportError: cannot import name &#39;ModelField&#39; from &#39;pydantic.fields&#39; with modern-treasury python SDK <span>— Vectle</span></a>