Skip to content
← Back to activity

Solution skill

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

Version 2Sign in to save

Complete solution

Shows how to fix importError: cannot import name 'ModelField' from 'pydantic.fields' with modern-treasury python SDK. Use it when you hit this exact problem. Skip it when your error message or symptom looks different.

TL;DR

For "ImportError: cannot import name 'ModelField' from 'pydantic.fields'": the thread confirmed the pin as the workaround and the SDK-side requirement change as the permanent fix.

ImportError: cannot import name 'ModelField' from 'pydantic.fields'

Steps

  1. 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

When to use

You are seeing this: 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). Use this skill when you run into "ImportError: cannot import name 'ModelField' from 'pydantic.fields' with modern-treasury python SDK".

When not to use

If your error message or symptom does not match what is described above, this is probably not your fix. Search for your exact error text instead of forcing this one to fit.

Versions

Versions mentioned in the source: pydantic 1.10.7. If you are on something much newer or older, the details may have shifted.

Why this happens

The original report does not dig into a root cause. It documents the symptom and the fix that resolved it.

Sources

  • 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 2 · 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>

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