aider icon indicating copy to clipboard operation
aider copied to clipboard

litellm APIConnection error - missing boto3

Open sringopi opened this issue 1 year ago • 11 comments

Issue

When running a model from Bedrock, getting a boto3 library error, potentially because of litellm issue.

 % aider --model bedrock/anthropic.claude-3-5-sonnet-20241022-v2:0
─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
Aider v0.70.0
Main model: bedrock/anthropic.claude-3-5-sonnet-20241022-v2:0 with diff edit format, infinite output
Weak model: bedrock/anthropic.claude-3-5-haiku-20241022-v1:0
Git repo: .git with 425 files
Repo-map: using 1024 tokens, auto refresh
─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
> help                                                                                                                                                               


litellm.APIConnectionError: Missing boto3 to call bedrock. Run 'pip install boto3'.
Traceback (most recent call last):
  File "/Users/tom/.local/share/uv/tools/aider-chat/lib/python3.12/site-packages/litellm/llms/bedrock/chat/converse_handler.py", line 206, in completion
    import boto3
ModuleNotFoundError: No module named 'boto3'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/tom/.local/share/uv/tools/aider-chat/lib/python3.12/site-packages/litellm/main.py", line 2610, in completion
    response = bedrock_converse_chat_completion.completion(
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/tom/.local/share/uv/tools/aider-chat/lib/python3.12/site-packages/litellm/llms/bedrock/chat/converse_handler.py", line 211, in completion
    raise ImportError("Missing boto3 to call bedrock. Run 'pip install boto3'.")
ImportError: Missing boto3 to call bedrock. Run 'pip install boto3'.

You need to: pip install boto3

─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
>  

Version and model info

Aider v0.70.0 Main model: bedrock/anthropic.claude-3-5-sonnet-20241022-v2:0 Testing on git repo of aider.

sringopi avatar Jan 02 '25 09:01 sringopi

boto3 is required to run bedrock models.

https://aider.chat/docs/llms/bedrock.html lists a few ways of installing boto3 so aider see's it. Depending on how you installed aider.

I could not get any method listed to work when installed with brew - so I uninstalled aider with brew, and re-installed using uv directly

mmorrisonnpa avatar Jan 06 '25 19:01 mmorrisonnpa

I'm running into the same issue with both the Homebrew installation and the public Docker image. Is there a specific reason why boto3 isn’t installed as a dependency in these cases, or was this an oversight?

Bedrock provides access to Anthropic models, making it a convenient option for privacy-conscious users who want to limit third-party data exposure.

From a business perspective, this is blocking engineers in my org from adopting Aider, as Bedrock is our only approved platform.

colout avatar Feb 04 '25 20:02 colout

Thanks for trying aider and filing this issue.

Homebrew is not a recommended method for installing aider. Try one of the recommended methods:

https://aider.chat/docs/install.html

You can then use these instructions for installing boto3:

https://aider.chat/docs/llms/bedrock.html#install-boto3

It's not installed by default as it's a large dependency that isn't needed by many users.

paul-gauthier avatar Feb 04 '25 20:02 paul-gauthier

Thanks for the quick and clear reply.

Is docker also not a recommened installation menthod?

paulgauthier/aider-full didn't have the boto3 dependency.

$ docker run --rm -it -v "$PWD":/aider -w /aider -e AWS_ACCESS_KEY_ID -e AWS_SECRET_ACCESS_KEY -e AWS_SESSION_TOKEN -e AWS_REGION paulgauthier/aider-full --model bedrock/anthropic.claude-3-5-sonnet-20241022-v2:0 --weak-model bedrock/anthropic.claude-3-5-haiku-20241022-v1:0 --no-show-release-notes --dark-mode --code-theme monokai
──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
Aider respects your privacy and never collects your code, chat messages, keys or personal info.
For more info: https://aider.chat/docs/more/analytics.html
Allow collection of anonymous analytics to help improve aider? (Y)es/(N)o [Yes]: n
Analytics have been permanently disabled.

Aider v0.73.0
Main model: bedrock/anthropic.claude-3-5-sonnet-20241022-v2:0 with diff edit format, infinite output
Weak model: bedrock/anthropic.claude-3-5-haiku-20241022-v1:0
Git repo: .git with 0 files
Repo-map: using 4096 tokens, auto refresh
──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
> hi


litellm.APIConnectionError: Missing boto3 to call bedrock. Run 'pip install boto3'.
Traceback (most recent call last):
  File "/venv/lib/python3.10/site-packages/litellm/llms/bedrock/chat/converse_handler.py", line 275, in completion
    from botocore.credentials import Credentials
ModuleNotFoundError: No module named 'botocore'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/venv/lib/python3.10/site-packages/litellm/main.py", line 2538, in completion
    response = bedrock_converse_chat_completion.completion(
  File "/venv/lib/python3.10/site-packages/litellm/llms/bedrock/chat/converse_handler.py", line 277, in completion
    raise ImportError("Missing boto3 to call bedrock. Run 'pip install boto3'.")
ImportError: Missing boto3 to call bedrock. Run 'pip install boto3'.

You need to: pip install boto3

──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
>

colout avatar Feb 04 '25 20:02 colout

It's fair for the "aider-full" docerfile to have that. The new aider-full:dev image is building now with it. Next release :latest will have it too.

paul-gauthier avatar Feb 04 '25 20:02 paul-gauthier

I worked around this issue today by:

  • Launch a new python:latest container (Python 3.13, yes I know it's not compatible with aider yet)
  • Install uv with pipx
  • Using uv to set up the Python 3.12.9 runtime
  • Install aider with uv as a "tool"
  • Install boto3 into the aider-chat Python virtual environment
pip3 install pipx
pipx install uv
pipx ensurepath
source ~/.bashrc
uv python install cpython-3.12.9-linux-aarch64-gnu
uv python pin cpython-3.12.9-linux-aarch64-gnu
uv tool run --from aider-chat pip install boto3

I think that is about right, but wrote it from memory ^^^

I just got done recording a 1.5 hour video on aider, including a live demo of this setup process with uv, inside of a Docker container. It'll be on this channel sometime soon: https://www.youtube.com/@GoForthandCloud/videos

It took me quite a while to figure out that aider doesn't support Python 3.13 at the moment. This is because numpy won't install, because Python removed distutils from the standard library.

Will aider be working around this limitation by upgrading to a newer numpy version, perhaps? Not entirely sure what the "correct" solution is for this.

pcgeek86 avatar Feb 18 '25 04:02 pcgeek86

I'm labeling this issue as stale because it has been open for 2 weeks with no activity. If there are no additional comments, I will close it in 7 days.

Note: A bot script made these updates to the issue.

github-actions[bot] avatar Mar 04 '25 12:03 github-actions[bot]

I worked around this issue today by:

  • Launch a new python:latest container (Python 3.13, yes I know it's not compatible with aider yet)
  • Install uv with pipx
  • Using uv to set up the Python 3.12.9 runtime
  • Install aider with uv as a "tool"
  • Install boto3 into the aider-chat Python virtual environment
pip3 install pipx
pipx install uv
pipx ensurepath
source ~/.bashrc
uv python install cpython-3.12.9-linux-aarch64-gnu
uv python pin cpython-3.12.9-linux-aarch64-gnu
uv tool run --from aider-chat pip install boto3

I think that is about right, but wrote it from memory ^^^

I just got done recording a 1.5 hour video on aider, including a live demo of this setup process with uv, inside of a Docker container. It'll be on this channel sometime soon: https://www.youtube.com/@GoForthandCloud/videos

It took me quite a while to figure out that aider doesn't support Python 3.13 at the moment. This is because numpy won't install, because Python removed distutils from the standard library.

Will aider be working around this limitation by upgrading to a newer numpy version, perhaps? Not entirely sure what the "correct" solution is for this.

@pcgeek86 Thanks for sharing, that approach didn't work for me. But pointed me in the right direction.

uv tool install --force --python python3.12 aider-chat@latest --with boto3

This solved issue at least for my setup

mdolinin avatar Mar 05 '25 17:03 mdolinin

The main branch aider will now offer to install this dependency, if needed.

The change is available in the main branch. You can get it by installing the latest version from github:

aider --install-main-branch

# or...

python -m pip install --upgrade --upgrade-strategy only-if-needed git+https://github.com/Aider-AI/aider.git

If you have a chance to try it, let me know if it works better for you.

paul-gauthier avatar Mar 06 '25 01:03 paul-gauthier

I'm labeling this issue as stale because it has been open for 2 weeks with no activity. If there are no additional comments, I will close it in 7 days.

Note: A bot script made these updates to the issue.

github-actions[bot] avatar Mar 20 '25 12:03 github-actions[bot]

I'm closing this issue because it has been stalled for 3 weeks with no activity. Feel free to add a comment here and we can re-open it. Or feel free to file a new issue at any time.

Note: A bot script made these updates to the issue.

github-actions[bot] avatar Mar 27 '25 12:03 github-actions[bot]