paul-gauthier / aider

aider is AI pair programming in your terminal
https://aider.chat/
Apache License 2.0
19.82k stars 1.81k forks source link

Uncaught ModuleNotFoundError in caching.py line 22 #1893

Open bhorton opened 1 hour ago

bhorton commented 1 hour ago

Aider version: 0.58.1 Python version: 3.11.1 Platform: Windows-10-10.0.19045-SP0 Python implementation: CPython Virtual environment: No OS: Windows 10 (64bit) Git version: git version 2.34.1.windows.1

An uncaught exception occurred:

Traceback (most recent call last):
  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "__main__.py", line 7, in <module>
    sys.exit(main())
             ^^^^^^
  File "main.py", line 537, in main
    main_model = models.Model(
                 ^^^^^^^^^^^^^
  File "models.py", line 646, in __init__
    res = self.validate_environment()
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "models.py", line 845, in validate_environment
    res = litellm.validate_environment(model)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  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 1206, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1178, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1149, 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 9, in <module>
    from litellm.caching import Cache
  File "caching.py", line 22, in <module>
    from openai._models import BaseModel as OpenAIObject
ModuleNotFoundError: No module named 'openai._models'
fry69 commented 1 hour ago

Thank you for filing this issue.

Can you please try to install or reinstall aider in a separate Python environment? Either with venv or pipx?

Please remove the existing environment/aider installation first, e.g. with pipx:

$ pipx uninstall aider-chat
uninstalled aider-chat! ✨ 🌟 ✨
$ pipx install aider-chat
  installed package aider-chat 0.58.1, installed using Python 3.12.6
  These apps are now globally available
    - aider
done! ✨ 🌟 ✨

This document may be helpful -> https://aider.chat/docs/troubleshooting/imports.html