How to upgrade AWS CLI to the latest version?

LinuxUbuntuAmazon Web-ServicesAmazon S3Aws Cli

Linux Problem Overview


I recently noticed that I am running an old version of AWS CLI that is lacking some functionality I need:

$aws --version
aws-cli/1.2.9 Python/3.4.3 Linux/3.13.0-85-generic

How can I upgrade to the latest version of the AWS CLI (1.10.24)?

Edit:

Running the following command fails to update AWS CLI:

$ pip install --upgrade awscli
Requirement already up-to-date: awscli in /usr/local/lib/python2.7/dist-packages
Cleaning up...

Checking the version:

$ aws --version
aws-cli/1.2.9 Python/3.4.3 Linux/3.13.0-85-generic

Linux Solutions


Solution 1 - Linux

From http://docs.aws.amazon.com/cli/latest/userguide/installing.html#install-with-pip

To upgrade an existing AWS CLI installation, use the --upgrade option:

pip install --upgrade awscli

Solution 2 - Linux

On Linux and MacOS X, here are the three commands that correspond to each step:

$ 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

Solution 3 - Linux

This does not work:

> pip install --upgrade awscli

This worked fine on Ubuntu 14.04( no need to reboot also .. You would have to first install pip3 ):

> pip3 install --upgrade awscli

Solution 4 - Linux

For Ubuntu 16.04 I used parts of the other answers and comments and just reloaded bash instead of rebooting.

I installed the aws-cli using apt so I removed that first:

sudo apt-get remove awscli

Then I could pip install (I chose to use sudo to install globally with pip2):

sudo pip install -U awscli

Since I was doing this on a server I didn't want to reboot it, but reloading bash did the trick:

source ~/.bashrc

At this point I could use the new version of aws cli

aws --version

Solution 5 - Linux

Update: Upgrade instance using AWS CLI v1 to AWS CLI v2:

This question and answer was initially created when there was only an AWS CLI v1. There is now a AWS CLI v2. The installation instructions for the AWS CLI v2 can be found here.

The new AWS CLI v2 has different installation instructions based on whether your EC2 instance is using Linux x86 (64-bit) or Linux ARM architecture.

To upgrade to AWS CLI v2, on an EC2 instance using Linux ARM, I had to issue the following commands:

rm -rf /bin/aws
curl "https://awscli.amazonaws.com/awscli-exe-linux-aarch64.zip" -o "awscliv2.zip"
unzip awscliv2.zip
./aws/install -i /usr/local/aws -b /bin

Subsequently test your AWS CLI version by executing: aws --version

For the Linux x86 (64-bit) architecture I'm hoping the commands are the same except for replacing the curl command with the following: (as per the installation instructions)

> curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o > "awscliv2.zip"

The AMI I used was the most recent one currently available and it was still using the AWS CLI v1. In the future if AWS starts packaging AWS CLI v2 with their AMIs this answer might require an update.


Original answer: Upgrade instance using AWS CLI v1 to use the most recent version of AWS CLI v1:

If you are having trouble installing the AWS CLI using pip you can use the "Bundled Installer" as documented here.

The steps discussed there are as follows:

$ 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

Check your AWS CLI version subsequently as a sanity-check that everything executed correctly:

$ aws --version

If the AWS CLI didn't update to the latest version as expected maybe the AWS CLI binaries are located somewhere else as the previously-given commands assume.

Determine where AWS CLI is being executed from:

$ which aws

In my case, AWS CLI was being executed from /bin/aws, so I had to install the "Bundled Installer" using that location as follows:

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

Solution 6 - Linux

Try sudo pip install --upgrade awscli, and open a new shell. This worked well for me (no need to reboot).

Solution 7 - Linux

Simple use sudo pip install awscli --force-reinstall --upgrade

This will upgrade all the required modules.

Solution 8 - Linux

On Mac you can use homebrew:

to install: brew install awscli

to upgrade: brew upgrade awscli

Make sure you don't have multiple installations: where aws

Solution 9 - Linux

pip install awscli --upgrade --user

The --upgrade option tells pip to upgrade any requirements that are already installed. The --user option tells pip to install the program to a subdirectory of your user directory to avoid modifying libraries used by your operating system.

Solution 10 - Linux

We can follow the below commands to install AWS CLI on UBUNTU:

> sudo apt install curl > > 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 > > rm -rf awscli-bundle.zip awscli-bundle > > To test: aws — version

For More Info :

https://gurudathbn.wordpress.com/2018/03/31/installing-aws-cli-on-ubuntu/

Solution 11 - Linux

When using sudo pip install --upgrade awscli I got the following error:

ERROR: Could not install packages due to an EnvironmentError: [Errno 30] Read-only file system: '/lib'

By using sudo with -H option, I could fix the problem.

sudo -H pip install --upgrade awscli

Solution 12 - Linux

Currently, using pip will get you the old version of awscli, 1.18.103.

The latest version of aws-cli, 2.0.33 is on the v2 branch. You can download the installer for Linux, Windows and macOS from here.

Solution 13 - Linux

I was trying to install awscli on one of my ec2 instances where I tried both

  • sudo pip install --upgrade awscli,
  • sudo pip3 install --upgrade awscli

which didn't worked, as I was getting errors like

> Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-2nh71cs2/cryptography/

And rebooting servers were not an option.

Luckily, simple

  • sudo apt update
  • sudo apt install awscli worked.

Solution 14 - Linux

I do it by removing & installing the awscli like described in this video

basically:

> pip uninstall awscliv2

> pip install awscliv2

> pip install awscliv2==your-version

> pip install awscliv

(you can keep v1 along with v2 if you want)

> pip install --upgrade ...

works as well. sure.

I do not install it globally (like some ppl seems still do), btw. Because sometimes I need different v for different cases. so I keep it in separate python virtual environment.

Solution 15 - Linux

Try AWS Cloud Shell, Quick and easy

AWS CloudShell is a browser-based shell that makes it easy to securely manage, explore, and interact with your AWS resources. CloudShell is pre-authenticated with your console credentials.

Benefits

  • No extra credentials to manage
  • Always up to date
  • No cost

More Details here https://aws.amazon.com/cloudshell/

  • Customizable

Solution 16 - Linux

To install globally, get on the sudo access sudo su & then upgrade aws cli by

pip3 install --upgrade awscli

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionBorealisView Question on Stackoverflow
Solution 1 - LinuxVijay DevView Answer on Stackoverflow
Solution 2 - LinuxAndong ZhanView Answer on Stackoverflow
Solution 3 - LinuxDeepak SinghalView Answer on Stackoverflow
Solution 4 - LinuxpetroleyumView Answer on Stackoverflow
Solution 5 - LinuxdutoitnsView Answer on Stackoverflow
Solution 6 - LinuxHadi PouransariView Answer on Stackoverflow
Solution 7 - LinuxKc BickeyView Answer on Stackoverflow
Solution 8 - LinuxDaniel BView Answer on Stackoverflow
Solution 9 - LinuxSemir HodzicView Answer on Stackoverflow
Solution 10 - LinuxGurudath BNView Answer on Stackoverflow
Solution 11 - LinuxStefan RodeView Answer on Stackoverflow
Solution 12 - LinuxBen ButterworthView Answer on Stackoverflow
Solution 13 - LinuxLokesh SoniView Answer on Stackoverflow
Solution 14 - LinuxsesView Answer on Stackoverflow
Solution 15 - LinuxRahulView Answer on Stackoverflow
Solution 16 - LinuxSandyView Answer on Stackoverflow