The words Under construction in black text on a yellow background with diagonal black stipes surrounding it
I'm in the process of moving my site. It's still a work in progress. Please excuse the mess and broken links.

How to Fix AWS CLI Tools When Homebrew Breaks Python

TODO: Pull subtitle into page object

I installed stunnel on my mac via homebrew. I wasn't expecting the Spanish Inquisition. Homebrew did a giant update including some craziness with Python. I'm not sure what happened, but it broke all my virtual environments. I thought those were supposed to be independent, but that's another story. They were easy enough to fix. I just blew them away and recreated them.

The other thing that went sideways was the AWS CLI. When I tried to run a command, I'd get this:

code_start_default_section code_end_default_section

Just installing over top might have worked, but the directions said to install the same way you did the first time. That's a poor UX, but it is what it is. Since I don't remember how I installed originally, I just nuked the site from orbit and started over. It's was the only way to be sure.

Debugging Stuff

I'm moving stuff around right now. All this below is helping me figure out where to put stuff

        -- title

How to Fix AWS CLI Tools When Homebrew Breaks Python

-- p

I installed <<link|stunnel|https://www.stunnel.org>> on my mac via homebrew. I wasn't expecting the Spanish Inquisition. Homebrew did a giant update including some craziness with Python. I'm not sure what happened, but it broke all my virtual environments. I thought those were supposed to be independent, but that's another story. They were easy enough to fix. I just blew them away and recreated them.

-- p

The other thing that went sideways was the <<link|AWS CLI|https://aws.amazon.com/cli/>>. When I tried to run a command, I'd get this:

-- code/
-- txt

$ aws s3 sync some/file.txt s3://bucket/some/file.txt
... A bunch of scary error code...
from hashlib import md5, sha1, sha256
ImportError: cannot import name md5*

-- /code

-- p

Per <<link|this page|https://medium.com/dev-genius/how-to-fix-md5-importerror-with-python-2-and-pip-cfe389dc24eb>>, I uninstalled the remains of homebrew's pytyon 2 via:

-- code/
-- txt

brew uninstall python@2

-- /code

-- p

After that, I tried another aws command:

-- code/
-- txt

$ aws s3 sync some/file.txt s3://bucket/some/file.txt
zsh: /usr/local/bin/aws: bad interpreter: /usr/local/opt/python@2/bin/python2.7: no such file or directory

-- /code

-- p

In fact, running just `aws` by itself produces the same error

-- p

Figured it was time to start over. My next step was to reinstall aws-cli.  The <<link|Amazon page|https://docs.aws.amazon.com/cli/latest/userguide/install-cliv2-mac.html>> for the aws-cli tool says to do updates the same way you did the initial install. I don't remember how I did that so I removed the existing install first. The note says to find your `aws` command with `which`:

-- code/
-- txt

$ which aws
/usr/local/bin/aws

-- /code

-- p

The notes say to uninstall `aws` and `aws_completer`, but there are other files there as well: `aws_bash_completer`, `aws_zsh_completer.sh` and `aws.cmd`. I deleted them with:

-- code/
-- txt

sudo rm /usr/local/bin/aws
sudo rm /usr/local/bin/aws.cmd
sudo rm /usr/local/bin/aws_bash_completer
sudo rm /usr/local/bin/aws_completer
sudo rm /usr/local/bin/aws_zsh_completer.sh

-- /code

-- p

I ran `which` again and there was another `aws` command floating around:

-- code/
-- txt

$ which aws
/Users/alans/Library/Python/3.7/bin/aws

-- /code

-- p

I tried using it, but got a similar error:

-- code/
-- txt

$ aws
zsh: /Users/alans/Library/Python/3.7/bin/aws: bad interpreter: /usr/local/opt/python/bin/python3.7: no such file or directory

-- /code

-- p

The same set of files was showed up in the new directory:

-- code/
-- txt

$ ll /Users/alans/Library/Python/3.7/bin/ |grep  aws
-rwxr-xr-x  1 alans  staff   834B Jun 11  2019 aws
-rwxr-xr-x  1 alans  staff   1.4K Jun 11  2019 aws.cmd
-rwxr-xr-x  1 alans  staff   204B Jun 11  2019 aws_bash_completer
-rwxr-xr-x  1 alans  staff   1.1K Jun 11  2019 aws_completer
-rwxr-xr-x  1 alans  staff   1.8K Jun 11  2019 aws_zsh_completer.sh

-- /code

-- p

I deleted them as well and finally cleared the system of the `aws` command.

-- code/
-- txt

$ which aws
aws not found

-- /code

-- p

The Amazon page also talks about deleting:

-- code/
-- txt

/usr/local/aws-cli

-- /code

-- p

But I didn't have that. So, I just moved on.

-- p

I installed aws-cli via the the mac gui and that got things working again.

-- code/
-- txt

aws --version
aws-cli/2.1.1 Python/3.7.4 Darwin/18.7.0 exe/x86_64

-- /code

-- p

Just installing over top might have worked, but the directions said to install the same way you did the first time. That's a poor UX, but it is what it is. Since I don't remember how I installed originally, I just nuked the site from orbit and started over. It's was the only way to be sure.


-- categories
-- AWS CLI
-- Miscellaneous
-- Python

-- metadata
-- date: 2020-11-17 00:00:00
-- id: 20enxcrv
-- status: published
-- type: post
-- SCRUBBED_NEO: false
-- site: aws