AWS throws the following error: "bad interpreter: No such file or directory"

10,022

Solution 1

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

Solution 2

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.

Solution 3

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

Solution 4

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... ;)

Share:
10,022
kris
Author by

kris

I've worked as a professional software developer in Australia, England, and Holland. I’ve also volunteered my skills with NGO’s in Africa and Asia. In 2011 I started the mobile app development business CoCreations.

Updated on June 04, 2022

Comments

  • kris
    kris almost 2 years

    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.

    • jarmod
      jarmod over 3 years
      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).
  • kris
    kris over 3 years
    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
  • BeeFriedman
    BeeFriedman over 3 years
    You also need to update to python 3.9. Look in to the post i linked above
  • BeeFriedman
    BeeFriedman over 3 years
    look in the following post as well it says that you have to give permissions to the config file.
  • kris
    kris over 3 years
    I only saw the same install command when following that link - what is the specific command to update to python 3.9 please ?
  • BeeFriedman
    BeeFriedman over 3 years
    you could also use the GUI downloader from python.org
  • kris
    kris over 3 years
    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...
  • Pateta
    Pateta over 3 years
    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
  • Aleksandr K.
    Aleksandr K. over 3 years
    @Pateta, thank you. Edited answer to fix this.