FG
🤖 AI & LLMsAnthropic

pydantic 1.10.13 error on anthropic 0.26.1

Freshabout 21 hours ago
Mar 14, 20260 views
Confidence Score47%
47%

Problem

Just a heads up. I am running the __Anthropic 0.26.1__ with __pydantic version 1.10.13__ and is throwing an error: _"ImportError: cannot import name 'version_short' from 'pydantic.version' (/opt/conda/lib/python3.10/site-packages/pydantic/version.cpython-310-x86_64-linux-gnu.so)"_ . The pyproject.toml asks for "pydantic>=1.9.0, <3"

Error Output

error:

_"ImportError: cannot import name 'version_short' from 'pydantic.version' (/opt/conda/lib/python3.10/site-packages/pydantic/version.cpython-310-x86_64-linux-gnu.so)"_ . 

Unverified for your environment

Select your OS to check compatibility.

1 Fix

Canonical Fix
Unverified Fix
New Fix – Awaiting Verification

Upgrade Pydantic to Resolve ImportError with Anthropic

Medium Risk

The error occurs because the 'version_short' attribute was removed in Pydantic version 1.10.0. Anthropic 0.26.1 likely relies on this attribute, which leads to the ImportError when using Pydantic 1.10.13. The specified version range in pyproject.toml allows for versions up to but not including 3.0, which means a compatible version of Pydantic must be used.

Awaiting Verification

Be the first to verify this fix

  1. 1

    Check Current Pydantic Version

    Verify the currently installed version of Pydantic to confirm it is causing the issue.

    bash
    pip show pydantic
  2. 2

    Upgrade Pydantic to a Compatible Version

    Upgrade Pydantic to a version that is compatible with Anthropic 0.26.1. Version 1.9.0 is the last version that supports 'version_short'.

    bash
    pip install 'pydantic<1.10.0'
  3. 3

    Verify Anthropic Functionality

    After upgrading Pydantic, test the functionality of Anthropic to ensure that the ImportError is resolved and that the application behaves as expected.

    bash
    python -c 'import anthropic; print(anthropic.__version__)'
  4. 4

    Update pyproject.toml

    Modify the pyproject.toml file to specify the compatible version of Pydantic to prevent future issues.

    bash
    echo 'pydantic>=1.9.0,<1.10.0' >> pyproject.toml
  5. 5

    Reinstall Dependencies

    Reinstall the project dependencies to ensure that all packages are aligned with the new version constraints.

    bash
    pip install -r requirements.txt

Validation

Run the application and check for the absence of the ImportError. Additionally, ensure that all functionalities of Anthropic are working as expected without errors.

Sign in to verify this fix

Environment

Submitted by

AC

Alex Chen

2450 rep

Tags

claudeanthropicllmapi