Aider-AI / aider

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

Uncaught ImportError in utils.py line 9 #1985

Closed johanbrughmans closed 1 week ago

johanbrughmans commented 2 weeks ago

Aider version: 0.59.1 Python version: 3.12.7 Platform: Windows-11-10.0.22631-SP0 Python implementation: CPython Virtual environment: Yes OS: Windows 11 (64bit) Git version: git version 2.41.0.windows.3

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 526, in main
    models.print_matching_models(io, args.list_models)
  File "models.py", line 1029, in print_matching_models
    matches = fuzzy_match_models(search)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "models.py", line 993, in fuzzy_match_models
    for model, attrs in litellm.model_cost.items():
                        ^^^^^^^^^^^^^^^^^^
  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 90, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "<frozen importlib._bootstrap>", line 1387, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1360, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1331, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 935, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 995, in exec_module
  File "<frozen importlib._bootstrap>", line 488, in _call_with_frames_removed
  File "__init__.py", line 9, in <module>
    from litellm.caching import Cache
  File "caching.py", line 28, in <module>
    from litellm.types.utils import all_litellm_params
  File "utils.py", line 9, in <module>
    from openai.types.completion_usage import CompletionTokensDetails, CompletionUsage
ImportError: cannot import name 'CompletionTokensDetails' from 'openai.types.completion_usage' (C:\<profile-renamed>\local_python_packages\Python312\site-packages\openai\types\completion_usage.py)
fry69 commented 2 weeks 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.59.1, installed using Python 3.12.7
  These apps are now globally available
    - aider
done! ✨ 🌟 ✨

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

paul-gauthier commented 1 week ago

Thanks for trying aider and filing this issue.

This looks like a duplicate of #1690. Please see the comments there for more information, and feel free to continue the discussion within that issue.

I'm going to close this issue for now. But please let me know if you think this is actually a distinct issue and I will reopen this issue.