AWS CLI $PATH Settings

纵饮孤独 提交于 2019-12-02 15:00:26
guru

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

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

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

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

Nami

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.

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.

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

conda install -c conda-forge awscli

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.

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 -O https://bootstrap.pypa.io/get-pip.py
python3 get-pip.py --user
pip3 install awscli --upgrade --user
aws --version

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!

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!