Menu
AWS Command Line Interface
User Guide

Install Python, pip, and the AWS Command Line Interface on Linux

You can install the AWS Command Line Interface and its dependencies on most Linux distributions with pip, a package manager for Python. The awscli package is available in repositories for other package managers such as APT and yum, but it is not guaranteed to be the latest version unless you get it from pip or use the bundled installer.

Amazon Linux

The AWS CLI comes pre-installed on the Amazon Linux AMI. Run sudo yum update after connecting to the instance to get the latest version of the package available via yum. If you need a more recent version of the AWS CLI than what is available in the Amazon updates repository, uninstall the package (sudo yum remove aws-cli) and then install using pip.

If you already have pip, follow the instructions in the main installation topic. Run pip --version to see if your version of Linux already includes Python and pip.

$ pip --version

Install Python

If your distribution did not come with Python, or came with an older version, install Python before installing pip and the AWS CLI.

To install Python 3 on Linux

  1. Check to see if Python is already installed:

    $ python --version

    Note

    If your Linux distribution came with Python, you may need to install the Python developer package in order to get the headers and libraries required to compile extensions and install the AWS CLI. Install the developer package (typically named python-dev or python-devel) using your package manager.

  2. If Python 2.7 or later is not installed, install Python 3 with your distribution's package manager. The command and package name varies:

    • On Debian derivatives such as Ubuntu, use APT:

      $ sudo apt-get install python3.4
    • On Red Hat and derivatives, use yum:

      $ sudo yum install python34
    • On SUSE and derivatives, use zypper:

      $ sudo zypper install python3-3.4.1
  3. Open a command prompt or shell and run the following command to verify that Python installed correctly:

    $ python3 --version
    Python 3.4.3

Install Pip and the AWS CLI

Install pip by using the script provided by the Python Packaging Authority, and then install the AWS CLI.

To install pip and the AWS CLI

  1. Download the installation script from pypa.io:

    $ curl -O https://bootstrap.pypa.io/get-pip.py

    The script downloads and installs the latest version of pip and another required package named setuptools.

  2. Run the script with Python:

    $ python3 get-pip.py --user

    Invoking version Python 3 directly by using the python3 command instead of python ensures that pip is installed in the proper location, even if an older system version of Python is present on your system.

  3. Add the executable path to your PATH variable: ~/.local/bin

    To modify your PATH variable (Linux, macOS, or Unix)

    1. Find your shell's profile script in your user folder. If you are not sure which shell you have, run echo $SHELL.

      $ ls -a ~
      .  ..  .bash_logout  .bash_profile  .bashrc  Desktop  Documents  Downloads
      • Bash.bash_profile, .profile, or .bash_login.

      • Zsh.zshrc

      • Tcsh.tcshrc, .cshrc or .login.

    2. Add an export command to profile script.

      export PATH=~/.local/bin:$PATH

      This command adds a path, ~/.local/bin in this example, to the current PATH variable.

    3. Load the profile into your current session.

      $ source ~/.bash_profile
  4. Verify that pip is installed correctly.

    $ pip --version
    pip 8.1.2 from ~/.local/lib/python3.4/site-packages (python 3.4)
  5. Finally, use pip to install the AWS CLI.

    $ pip install awscli --upgrade --user
  6. Verify that the AWS CLI installed correctly.

    $ aws --version
    aws-cli/1.11.44 Python/3.4.3 Linux/4.4.0-59-generic botocore/1.5.7

    If you get an error, see Troubleshooting AWS CLI Installations.

To upgrade to the latest version, run the installation command again:

$ pip install awscli --upgrade --user

Troubleshooting AWS CLI Installations

After installing with pip, you may need to add the aws executable to your OS's PATH environment variable, or change its mode to make it executable.

Example AWS CLI install location - Linux with pip (user mode)

~/.local/bin

If you see an error message like -bash: aws: command not found when you try to use the AWS CLI, add the location of the executable to your PATH environment variable.

To modify your PATH variable (Linux, macOS, or Unix)

  1. Find your shell's profile script in your user folder. If you are not sure which shell you have, run echo $SHELL.

    $ ls -a ~
    .  ..  .bash_logout  .bash_profile  .bashrc  Desktop  Documents  Downloads
    • Bash.bash_profile, .profile, or .bash_login.

    • Zsh.zshrc

    • Tcsh.tcshrc, .cshrc or .login.

  2. Add an export command to profile script.

    export PATH=~/.local/bin:$PATH

    This command adds a path, ~/.local/bin in this example, to the current PATH variable.

  3. Load the profile into your current session.

    $ source ~/.bash_profile

If you see permission denied when you try to use the AWS CLI, make sure that the aws script has a file mode that is executable. For example, 755.

To make the aws script executable

  1. Locate the script.

    $ which aws
    ~/.local/bin
  2. Run chmod +x to make the file executable.

    $ chmod +x ~/.local/bin