Python3 and aws-cli version differ

Viewed 459

I installed aws-cli following the aws docs

$ curl "https://awscli.amazonaws.com/AWSCLIV2.pkg" -o "AWSCLIV2.pkg"
$ sudo installer -pkg AWSCLIV2.pkg -target /

When I verify their existence I get different Python versions.

$ python3 --version
Python 3.9.6

$ aws --version
aws-cli/2.2.26 Python/3.8.8 Darwin/20.6.0 exe/x86_64 prompt/off

Is this expected?

2 Answers

yeah that's expected. The CLI doesn't use your OS'es python, one is bundled into .pkg file as well as all other dependencies. This simplifies installation, testing and development. you can mess around with your OS's python all you like without breaking the CLI.

the guts of the code for this is here: https://github.com/aws/aws-cli/blob/v2/scripts/make-bundle

When you use sudo for installing the package you are not referring to what's specific to your user's settings, the python version is one of those settings.

Python 3.8.8 is the system installed version( System Installed

Python 3.9.6 is specific to your user's settings, you might be using pipenv or any other setting which sets the python version for you.

Hence the differences.

$›› sudo python --version
Password:
Python 2.7.16
$›› python --version
Python 2.7.16
Related