AWS CLI $PATH Settings

I am following the AWS CLI Setup guide. I have managed to successfully install the tool on my Mac OS X terminal with the following output:

Running cmd: /usr/bin/python virtualenv.py --python /usr/bin/python /Users/fr/.local/lib/aws
Running cmd: /Users/fr/.local/lib/aws/bin/pip install --no-index --find-links file:///Users/fr/Downloads/awscli-bundle/packages awscli-1.5.3.tar.gz
You can now run: /Users/fr/.local/lib/aws/bin/aws --version

My issue is that I have to type the full path /Users/fr/.local/lib/aws/bin/aws to execute any aws command. As per the guide's final step, I should be able to execute aws command directly without typing the absolute path for it to execute.

When I try using just aws, I get the following output:

aws --version                                                                                         ⏎
command not found: aws

I followed the instructions to make sure that ~/bin is in my PATH environment and I could see there was no output, hence, I executed the export PATH=~/bin:$PATH command to add ~/bin to $PATH. But this has made no difference. The aws command does not work directly.

Could someone please advise what could be going wrong?

111564 次浏览

Try:

PATH=/Users/fr/.local/lib/aws/bin:$PATH

(put it in .profile file)

Also try to install aws cli with homebrew. It will add it to your path automatically.

Here are the three steps to install AWS cli on mac OSX (curl or wget) The third step will set you path correctly

$ curl "https://s3.amazonaws.com/aws-cli/awscli-bundle.zip" -o "awscli-bundle.zip"
$ unzip awscli-bundle.zip
$ sudo ./awscli-bundle/install -i /usr/local/aws -b /usr/local/bin/aws

The other easiest way is to do using homebrew

brew install awscli

If you want the development version you can do

brew install awscli --HEAD

I have used Homebrew to install AWS CLI and I am quite happy with the result. Simply type:

$ brew install awscli

after you have installed brew.

Note, on the AWS CLI installation page there is the following disclaimer:

The awscli package may be available in repositories for other package managers such as APT, yum and Homebrew, but it is not guaranteed to be the latest version.

That said, I have not found this to be a problem, the awscli.rb has been updated quite frequently to match the latest releases.


Update: there is a GitHub issue that suggests that Homebrew should be added as an alternative in the AWS CLI installation instructions. This issue was later closed in favor of this UserVoice feature request.

This happened to me as well and did not want to install brew anymore, because everything was running fine already. I also followed the 'tutorial' on AWS site and had problem in the export path step.

Basically, it added a different python folder as the one, where awscli was downloaded. So instead of export PATH=~/.local/bin:$PATH what they suggested I used a full path from disk: export PATH=/Users/abc/Library/Python/3.6/bin/:$PATH

This worked for me (note: change 2.7 to your specific Python version):

export PATH=~/Library/Python/2.7/bin/:$PATH

You'll likely want to add this to the end of your .bash_profile using:

sudo nano ~/.bash_profile

I've just had the same error and I was able to solve it by adding the following line to my .bash_profile file:

export PATH=~/Library/Python/2.7/bin/:$PATH

Please check the version of Python as it may be slightly different on your system. This avoids adding your username folder to the .bash_profile file.

I ended up doing the same as Piotr and it's good to understand how to update your path without 3rd party software. However as 3rd party software goes Homebrew is pretty awesome and its a good thing to use it for keeping your dependency symlinks controlled in one place. de facto pkg mgr on mac.

when you run the command: pip3 install awscli --upgrade --user

watch closely where the aws cli tool gets installed, you can see the path on terminal log, in my case I got something like this:

awscli in ./Library/Python/3.6/lib/python/site-packages

Now you should add to your .bash_profile the same path but on the bin folder(removing from the lib path and instead put your bin path) like this:

export PATH=/Users/xuser/Library/Python/3.6/bin/:$PATH

If you have Anaconda version of python on your system, please use conda to install awscli:

conda install -c conda-forge awscli

This appears to be the Virtual Environment method at: https://docs.aws.amazon.com/cli/latest/userguide/awscli-install-virtualenv.html

without activating the virtualenv: source ~/cli-ve/bin/activate in the documented example.

Take a look at the note on https://docs.aws.amazon.com/cli/latest/userguide/install-bundle.html

By default, the install script runs under the system default version of Python. If you have installed an alternative version of Python and want to use that to install the AWS CLI, run the install script with that version by absolute path to the Python executable.

For the step where you run the install executable

instead of doing just:

$ sudo ./awscli-bundle/install -i /usr/local/aws -b /usr/local/bin/aws

Find out where your python is installed for example

$ which python

and then use the path to install the executable like

$ sudo <path from executing which python> awscli-bundle/install -i /usr/local/aws -b /usr/local/bin/aws

The above should fix the problem.

I personally had the same issue with aws CodeBuild - I couldn't use the aws cli. I solved it by installing aws globally on my docker image (instead of installing it locally to a user).

RUN pip install awscli --upgrade


(instead of RUN pip install awscli --upgrade --user)

It worked for me, if that can help anyone !

Make sure python is installed globally, The steps are like this:

On AWS side:

Go to amazon AWS center -> Services -> Identity and Access Management (IAM) -> Users -> find your User and click on it -> pick Security Credentials tab -> create Access Key

Installation: On command line / bash

curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip"
unzip awscliv2.zip
sudo ./aws/install

Optional: if aws version is not found yet ,set up the aws path on your bash profile.

vim ~/.bash_profile
#paste this line
PATH=$PATH:/usr/local/bin/aws

Configuration:(Final Step) Configure your credentials as following

aws configure

Fill in the properties you got from aws website and connect your account. attaching an example for this step.

AWS Access Key ID [None]: abcd

AWS Secret Access Key [None]: zyx123!@#

Default region> name [None]: us-east-1

Default output format [None]: json

Good Luck!

sometimes while classpath's are messed up on mac - you could always run to fix aws cli locally

$ brew install awscli

which would re-use and update the existing package and set up the right classpath

I try usigng CLI

$ curl "https://s3.amazonaws.com/aws-cli/awscli-bundle.zip" -o "awscli-bundle.zip"


$ unzip awscli-bundle.zip


$ sudo ./awscli-bundle/install -i /usr/local/aws -b /usr/local/bin/aws

export PATH=~/Library/Python/3/bin/:$PATH

try it and add this to the end of your bash

hopefully it worked.