aider icon indicating copy to clipboard operation
aider copied to clipboard

Uncaught ImportError in _types.py line 10

Open moneysavvy opened this issue 1 year ago • 1 comments

Aider version: <module 'aider.version' from '/opt/anaconda3/lib/python3.11/site-packages/aider/version.py'> Python version: 3.11.7 Platform: macOS-15.0-arm64-arm-64bit Python implementation: CPython Virtual environment: No OS: Darwin 24.0.0 (64bit) Git version: git version 2.45.2

An uncaught exception occurred:

Traceback (most recent call last):
  File "base_coder.py", line 1124, in send_message
    yield from self.send(messages, functions=self.functions)
  File "base_coder.py", line 1396, in send
    hash_object, completion = send_completion(
                              ^^^^^^^^^^^^^^^^
  File "sendchat.py", line 86, in send_completion
    res = litellm.completion(**kwargs)
          ^^^^^^^^^^^^^^^^^^
  File "llm.py", line 23, in __getattr__
    self._load_litellm()
  File "llm.py", line 30, in _load_litellm
    self._lazy_module = importlib.import_module("litellm")
                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "<frozen importlib._bootstrap>", line 1204, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1176, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1147, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 690, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 940, in exec_module
  File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
  File "__init__.py", line 20, in <module>
    from litellm.proxy._types import (
  File "_types.py", line 10, in <module>
    from pydantic import BaseModel, ConfigDict, Extra, Field, Json, model_validator
ImportError: cannot import name 'model_validator' from 'pydantic' (/opt/anaconda3/lib/python3.11/site-packages/pydantic/__init__.cpython-311-darwin.so)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "aider", line 8, in <module>
    sys.exit(main())
             ^^^^^^
  File "main.py", line 698, in main
    coder.run()
  File "base_coder.py", line 735, in run
    self.run_one(user_message, preproc)
  File "base_coder.py", line 778, in run_one
    list(self.send_message(message))
  File "base_coder.py", line 1126, in send_message
    except retry_exceptions() as err:
           ^^^^^^^^^^^^^^^^^^
  File "sendchat.py", line 24, in retry_exceptions
    litellm.exceptions.APIConnectionError,
    ^^^^^^^^^^^^^^^^^^
  File "llm.py", line 23, in __getattr__
    self._load_litellm()
  File "llm.py", line 30, in _load_litellm
    self._lazy_module = importlib.import_module("litellm")
                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "<frozen importlib._bootstrap>", line 1204, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1176, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1147, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 690, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 940, in exec_module
  File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
  File "__init__.py", line 20, in <module>
    from litellm.proxy._types import (
  File "_types.py", line 10, in <module>
    from pydantic import BaseModel, ConfigDict, Extra, Field, Json, model_validator
ImportError: cannot import name 'model_validator' from 'pydantic' (/opt/anaconda3/lib/python3.11/site-packages/pydantic/__init__.cpython-311-darwin.so)

moneysavvy avatar Sep 13 '24 03:09 moneysavvy

Thank you for filing this issue.

How did you install aider?

If you installed it via homebrew, please try using pipx instead.

Sadly pip and package manger like homebrew either interfere with the main Python installation or get the dependencies wrong. pipx on macOS works reliably (it is basically an automatic venv manager), I strongly recommend to use this method to install aider.

fry69 avatar Sep 13 '24 04:09 fry69

This looks like a duplicate of #1437, so I'm going to close it so discussion can happen there. Please let me know if you think it's actually a distinct issue.

paul-gauthier avatar Sep 20 '24 18:09 paul-gauthier