Aider-AI / aider

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

Uncaught ModuleNotFoundError in caching.py line 22 #1726

Closed tonyrb closed 3 weeks ago

tonyrb commented 3 weeks ago

Aider version: 0.57.1 Python version: 3.9.12 Platform: macOS-10.16-x86_64-i386-64bit Python implementation: CPython Virtual environment: No OS: Darwin 23.4.0 (64bit) Git version: git version 2.46.0

An uncaught exception occurred:

Traceback (most recent call last):
  File "base_coder.py", line 1115, in send_message
    yield from self.send(messages, functions=self.functions)
  File "base_coder.py", line 1392, in send
    hash_object, completion = send_completion(
  File "sendchat.py", line 87, 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 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1030, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
  File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 680, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 850, in exec_module
  File "<frozen importlib._bootstrap>", line 228, 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'

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 709, in main
    coder.run()
  File "base_coder.py", line 723, in run
    self.run_one(user_message, preproc)
  File "base_coder.py", line 766, in run_one
    list(self.send_message(message))
  File "base_coder.py", line 1117, 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 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1030, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
  File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 680, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 850, in exec_module
  File "<frozen importlib._bootstrap>", line 228, 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'
tonyrb commented 3 weeks ago

Installed the newest version and getting this error straight even with the following prompt 'which model are you?' I will return to previous version in case

fry69 commented 3 weeks ago

Thank you for filing this issue.

This error is likely due to something gone wrong during installation. Can you please try to install aider separately from other Python modules, e.g. via pipx or venv?

tonyrb commented 3 weeks ago

Thank you for filing this issue.

This error is likely due to something gone wrong during installation. Can you please try to install aider separately from other Python modules, e.g. via pipx or venv?

I did try to reinstall through pipx and same error happened, I have rollback to previous version and work as a charm.

fry69 commented 3 weeks ago

I did try to reinstall through pipx and same error happened, I have rollback to previous version and work as a charm.

Can you please post the first few lines from aider when you start from the version that is not working, please? Also try really uninstalling and reinstalling aider via pipx, if possible, please->

$ pipx uninstall aider-chat
uninstalled aider-chat! ✨ 🌟 ✨
$ pipx install aider-chat
  installed package aider-chat 0.57.1, installed using Python 3.12.6
  These apps are now globally available
    - aider
done! ✨ 🌟 ✨
$ aider --4o
Aider v0.57.1
Main model: gpt-4o-2024-08-06 with ask edit format
Weak model: gpt-4o-mini
Git repo: .git with 6 files
Repo-map: using 1024 tokens, auto refresh
Use /help <question> for help, run "aider --help" to see cmd line args

ask> Please say something in English.                                                                                                                         

Of course! If you have any questions about your code or need help with anything specific, feel free to ask.                                                   

Tokens: 160 sent, 23 received. Cost: $0.00063 message, $0.00063 session.

Works for me without problems on my macOS M1 system.

tonyrb commented 3 weeks ago

Well thanks for the uninstall reinstall, it did fix the issue. Thanks for the support for this dumb bug that I got :/

tonyrb commented 3 weeks ago

closing the ticket thanks Fry69 !