change the AWS CLI from 1 to 2

Viewed 1900

When checking the AWS PATH with which aws when changing the AWS CLI from 1 to 2

/Users/username/.pyenv/shims/aws

I used to install via pyenv, but I want to remove it and install it according to system 2, but even if I try it according to the official doc, it is not changed to system 2. https://docs.aws.amazon.com/cli/latest/userguide/install-cliv2-mac.html

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

It did not change to the 2 system even if I typed this command.

I've also tried uninstalling the AWS CLI, but it doesn't work. Does anyone know of any way to do this?

thank you

2 Answers

I removed my old aws cli from ~/.pyenv/versions/x.x.x/bin/aws, where x.x.x is the current Python version.

Get the current version:

$ pyenv versions
* 3.7.4 

Remove aws cli from current pyenv bin:

$ rm -rf ~/.pyenv/versions/3.7.4/bin/aws*

Try again which aws:

$ which aws 
/usr/local/bin/aws

I had the same issue. This is because pyenv linked the shim to very Python version that command has been installed originally with; that's by the way ok to avoid version conflicts. pip3 and awscli v3 uninstall don't take care of that. What you have to do is to:

  1. First, uninstall the old awscli as noted in the AWS documentation (probably you used pip3). Note: remember to edit your bash_profile or zshrc as you may have a $HOME/.local/bin PATH in your config: you want to remove that too

  2. The aws shim will remain in place until you get rid of that Python version (pyenv uninstall 3.7.x) BUT YOU PROBABLY DON'T WANT THAT

  3. Just remove the shim manually rm /Users/username/.pyenv/shims/aws

  4. Install the AWS CLI v2 using the recommended installed and verify everything works correctly

Related