"bash: aws: command not found" on Windows 7 in Git Bash

15,113

Solution 1

Fixed this by simply installing the AWS CLI again but this time using Git Bash instead of the Windows command prompt.

pip install awscli

If anyone could provide some insight as to why this was necessary, it would be appreciated.

Solution 2

In my case, I think a recent-to-me update to the AWS CLI changed what's run to being aws.cmd (full path C:\Program Files\Amazon\AWSCLI\bin\aws.cmd)

Git Bash needs the extension aws.cmd to make it work.

In Bash, you could try typing aws.cmd vs aws. If the former works, but not the latter, you can do alias aws='aws.cmd' in your bash startup script. I don't know if it's the best solution, but it worked for me.

FWIW, I think it's related to this: https://unix.stackexchange.com/questions/280528/is-there-a-unix-equivalent-of-the-windows-environment-variable-pathext

Solution 3

On Windows 10 I was installing just once from GitBash via pip install awscli --upgrade --user as described in AWS manual for CLI installation for Linux

It installed aws executables into %USERPROFILE%\AppData\Roaming\Python\Python37\Scripts

After that just add this folder to your PATH. Re-open GitBash or cmd - it should work from both places

Share:
15,113
David
Author by

David

Most of my experience is with C#, AWS, and JavaScript (especially Angular). I'm a certified AWS Cloud Solutions Architect, though most of my work has been on developing user interfaces for various medical technologies.

Updated on June 08, 2022

Comments

  • David
    David almost 2 years

    I'm trying to use AWS CLI to access CodeCommit. And it's sort of working. I am able to use the aws command in the Windows command prompt. However, when I try to access it using the Git Bash shell, it says

    "bash: aws: command not found."

    Additionally, when I try to do do a git clone in the Windows command promt, trying to access CodeCommit, it tries to use aws using the credentials helper, which also results in "aws: command not found."

    enter image description here

    I followed the instructions in the AWS documentation, which suggests some directories to add to the PATH:

    https://docs.aws.amazon.com/cli/latest/userguide/awscli-install-windows.html#awscli-install-windows-path

    Here's what my PATH variable looks like:

    C:\Users\ddrayton\AppData\Local\Programs\Python\Python36\Scripts\;C:\Users\ddrayton\AppData\Local\Programs\Python\Python36\;C:\Windows\System32;;C:\Program Files\Docker Toolbox;C:\Users\ddrayton\MyCurl;%USERPROFILE%\AppData\Local\Programs\Python\Python36\Scripts;C:\Program Files\Amazon\AWSCLI;C:\Program Files (x86)\Amazon\AWSCLI;C:\Users\ddrayton\AppData\Local\Programs\Python\Python36;C:\Users\ddrayton\AppData\Local\Programs\Python\Python36\Scripts

    But I'm not sure if it's a PATH problem, since the Windows command prompt has no problem accessing the "aws" command.

    Any ideas?

  • Andrey Tagaew
    Andrey Tagaew over 5 years
    This helped me. In my situation i even did not have pip installed. So I had to install Pithon, then use the pip command above. Thank you very much!
  • David
    David over 5 years
    I should note that although this solution fixed my problem on one computer, it did NOT fix my problem on my other computer. :-(
  • Vishwakant
    Vishwakant over 3 years
    It worked for me, i also faced same problem, aws command was working fine in command prompt but not in git bash.
  • Olumide
    Olumide over 2 years
    I didn't have to run pip install awscli I simply installed awscli via the windows UI installer and then restarted my code editor and terminal and it worked