Skip to content

Error while importing pydantic_ai #1635

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
2 tasks done
RahulDas-dev opened this issue May 2, 2025 · 2 comments
Closed
2 tasks done

Error while importing pydantic_ai #1635

RahulDas-dev opened this issue May 2, 2025 · 2 comments
Assignees
Labels
question Further information is requested

Comments

@RahulDas-dev
Copy link

Initial Checks

Description

While Importing paydantic_ai i am faceing error - AttributeError: module 'wrapt' has no attribute 'AdapterFactory'

(doc-infer) D:\python\doc-inference>python
Python 3.11.6 (tags/v3.11.6:8b6ee5b, Oct  2 2023, 14:57:12) [MSC v.1935 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>>
>>>
>>>
>>>
>>> from pydantic_ai import Agent, ModelRetry
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "D:\python\doc-inference\.venv\Lib\site-packages\pydantic_ai\__init__.py", line 3, in <module>
    from .agent import Agent, CallToolsNode, EndStrategy, ModelRequestNode, UserPromptNode, capture_run_messages
  File "D:\python\doc-inference\.venv\Lib\site-packages\pydantic_ai\agent.py", line 13, in <module>
    from opentelemetry.trace import NoOpTracer, use_span
  File "D:\python\doc-inference\.venv\Lib\site-packages\opentelemetry\trace\__init__.py", line 83, in <module>
    from deprecated import deprecated
  File "D:\python\doc-inference\.venv\Lib\site-packages\deprecated\__init__.py", line 15, in <module>
    from deprecated.classic import deprecated
  File "D:\python\doc-inference\.venv\Lib\site-packages\deprecated\classic.py", line 35, in <module>
    class ClassicAdapter(wrapt.AdapterFactory):
                         ^^^^^^^^^^^^^^^^^^^^
AttributeError: module 'wrapt' has no attribute 'AdapterFactory'
>>> exit()

Image

Image

Example Code

from pydantic_ai import Agent, ModelRetry

Python, Pydantic AI & LLM client version

Python : Python 3.11.6 
OS: Windows


D:\python\doc-inference>uv add pydantic-ai-slim[openai]
Resolved 144 packages in 995ms
Prepared 6 packages in 609ms
░░░░░░░░░░░░░░░░░░░░ [0/13] Installing wheels...                                                                        warning: Failed to hardlink files; falling back to full copy. This may lead to degraded performance.
         If the cache and target directories are on different filesystems, hardlinking may not be supported.
         If this is intentional, set `export UV_LINK_MODE=copy` or use `--link-mode=copy` to suppress this warning.
Installed 13 packages in 306ms
 + deprecated==1.2.18
 + distro==1.9.0
 + eval-type-backport==0.2.2
 + griffe==1.7.3
 + importlib-metadata==8.6.1
 + jiter==0.9.0
 + logfire-api==3.14.1
 + openai==1.76.2
 + opentelemetry-api==1.32.1
 + pydantic-ai-slim==0.1.9
 + pydantic-graph==0.1.9
 + tqdm==4.67.1
 + typing-inspection==0.4.0
@DouweM
Copy link
Contributor

DouweM commented May 2, 2025

@RahulDas-dev Does the source of D:\python\doc-inference\.venv\Lib\site-packages\wrapt\__init__.py match that in https://github.com/GrahamDumpleton/wrapt/blob/f3fa91652266a3a99912e0f8290b574827e845c6/src/wrapt/__init__.py#L13? It imports the AdapterFactory, so it should be available to deprecated which imports wrapt. It seems like there was an issue installing the packages. I notice you also filed #1633, where you don't seem to hit this issue. Did you manage to fix it, or is it only happening sometimes?

@DouweM DouweM self-assigned this May 2, 2025
@DouweM DouweM added question Further information is requested and removed need confirmation labels May 2, 2025
@RahulDas-dev
Copy link
Author

I removed the entire virtual environment and performed a fresh installation using uv install. The issue no longer occurs, and I'm currently struggling to reproduce it

@DouweM DouweM closed this as not planned Won't fix, can't repro, duplicate, stale May 5, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants