14

I'm not aware of anything on my system having changed, but the aws CLI tool has stopped working.

$ aws-bash: /Users/user_name/Library/Python/3.7/bin/aws:/usr/local/opt/python/bin/
python3.7: bad interpreter: No such file or directory

I've tried brew reinstall awscli which is suggested elsewhere, but with no luck.

1
  • 2
    If you edit /Users/user_name/Library/Python/3.7/bin/aws you'll presumably see that its shebang indicates /usr/local/opt/python/bin/python3.7 which no longer exists (either you deleted it or some automation deleted it).
    – jarmod
    Commented Oct 20, 2020 at 3:10

5 Answers 5

26

Option 1

Type

brew uninstall awscli

Then

brew install awscli

update python to 3.9. look in the following post.

If this approach does not work for you, then try :

Option 2

  1. Go to https://www.python.org/ and use the GUI installer for your OS

  2. pip3 install awscli

6
  • Thanks - but this makes no difference -- even after following the prompts of the install which said to do brew link awscli and brew link --overwrite awscli
    – kris
    Commented Oct 20, 2020 at 2:47
  • You also need to update to python 3.9. Look in to the post i linked above Commented Oct 20, 2020 at 2:49
  • look in the following post as well it says that you have to give permissions to the config file. Commented Oct 20, 2020 at 2:52
  • 1
    you could also use the GUI downloader from python.org Commented Oct 20, 2020 at 2:58
  • 2
    That did it @CForce99 -- installing python using the Mac installer, and then running pip3 install awscli (which then finally worked) -- THANK YOU !! OH - but now it turns out the aws command I'm using needs the CLI v2 .. I'll follow the instructions it's giving me there and hopefully get to the end...
    – kris
    Commented Oct 20, 2020 at 3:07
14

Another solution

# Reinstall awscli using your latest/current Python installation
brew reinstall awscli

# Overwrite the existing /usr/local/bin/aws with the new installation
brew link --overwrite awscli
5

Another option would be to look into .bash_profile or .zshrc, look for line that looks like this:

export PATH=/Users/user_name/Library/Python/3.7/bin/:$PATH

Try commenting it first. If it works for you - remove it.

What this line does is prepending the lookup path for binaries, which in turn takes priority over brew installation.

2
  • 1
    Please note that "$" is missing in ":$PATH". This will remove all your path from the current session. Do not put this into bash_profile or similar
    – Pateta
    Commented Jan 11, 2021 at 14:32
  • @Pateta, thank you. Edited answer to fix this. Commented Jan 12, 2021 at 12:18
5

You probably don't need to reinstall awscli, but just update its Python path.

Check which Python versions are installed:

ls /usr/bin/python*
# /usr/bin/python2    /usr/bin/python3    /usr/bin/python2.7  /usr/bin/python3.6

python3 -V
# Python 3.6.8

Locate aws command, and update its python path:

which aws
# ~/.local/bin/aws

vi ~/.local/bin/aws
#!/usr/bin/python3

Try to call aws again:

$ aws
# usage: aws [options] <command> <subcommand> [<subcommand> ...] [parameters]
1

I solved this issue by reviewing my .bash_profile. There was an old entry which got invalid after updating python.

Just for the case someone also forgot to look the obvious first, like me... ;)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.