Installing and updating the AWS CLI version 1 in a virtual environment - AWS Command Line Interface

This documentation is for Version 1 of the AWS CLI only. For documentation related to Version 2 of the AWS CLI, see the Version 2 User Guide.

Installing and updating the AWS CLI version 1 in a virtual environment

You can avoid requirement version conflicts with other pip packages by installing version 1 of the AWS Command Line Interface (AWS CLI) in a virtual environment.

Prerequisites

  • Python 3.8 or later. For installation instructions, see the Downloading Python page in Python's Beginner Guide.

    Python version support matrix

    AWS CLI version Supported Python version
    1.32.0 – current Python 3.8+
    1.27.0 – 1.31.x Python 3.7+
    1.20.0 – 1.26.x Python 3.6+
    1.19.0 – 1.19.x Python 2.7+, Python 3.6+
    1.17 – 1.18.x Python 2.7+, Python 3.4+
    1.0 – 1.16.x Python 2.6 and older, Python 3.3 and older
  • pip or pip3 is installed.

Install and update the AWS CLI version 1 in a virtual environment

  1. Install virtualenv using pip.

    $ pip install --user virtualenv
  2. Create a virtual environment and name it.

    $ virtualenv ~/cli-ve

    Alternatively, you can use the -p option to specify a version of Python other than the default.

    $ virtualenv -p /usr/bin/python37 ~/cli-ve
  3. Activate your new virtual environment.

    Linux or macOS

    $ source ~/cli-ve/bin/activate

    Windows

    $ %USERPROFILE%\cli-ve\Scripts\activate

    The prompt changes to show that your virtual environment is active.

    (cli-ve)~$
  4. Install or update the AWS CLI version 1 into your virtual environment.

    (cli-ve)~$ pip install --upgrade awscli
  5. Verify that the AWS CLI version 1 is installed correctly.

    $ aws --version aws-cli/1.35.20 Python/3.11.6 Linux/5.10.205-195.807.amzn2.x86_64 botocore/1.18.6
  6. You can use the deactivate command to exit the virtual environment. Whenever you start a new session, you must reactivate the environment.

Troubleshooting AWS CLI install and uninstall errors

If you come across issues after installing or uninstalling the AWS CLI, see Troubleshooting errors for the AWS CLI for troubleshooting steps. For the most relevant troubleshooting steps, see Command not found errors, The "aws --version" command returns a different version than you installed, and The "aws --version" command returns a version after uninstalling the AWS CLI.