I get a Python No module named'encodings' error with the aws command

Overview

When I run the AWS CLI command on my Mac, I started getting the command No module named'encodings'. I'm writing a lot about what I did at this time. However, to conclude first, I reinstalled __Python3 __ and fixed it.

What I tried with the event

When I execute the aws command, I get the following error and try various googles. As a side note, since we are using Python in the AWS CLI, Python must also be configured correctly.

$ aws configure --profile XXXX
...(abridgement)...
Fatal Python error: Py_Initialize: Unable to get the locale encoding
ImportError: No module named 'encodings'
...(abridgement)...

I tried all the path related fixes.

1. Try changing the PYTHON HOME settings

--When I googled the error, a page saying that the path of PYTHONHOME was suspected appeared, so when I checked .bash_profile, it was certainly not set. Therefore, I decided to set the default value / usr / local. --As a result, the error has changed, but I get another __syntax error` __...

2. Try changing the PYTHONPATH setting

--I tried setting various values in .bash_profile in the same way, but even if the error changed, it could not be solved ...

On Mac, / usr / bin / python is the Python2 version by default. Therefore, I installed Python3 using another tool such as pyenv or Anaconda, but at this time I did not change the path of Python3 from / usr / bin / python. It seems that the path of Pyhton 3 has gone wrong while working on various things. __ * It is thought that the cause was not pyenv or Anaconda, but the environment was destroyed during the work. __

solution

After uninstalling pyenv and Andaconda, I reinstalled Python3 by referring to the following. [Python3] Summary of steps to install the latest version of Python on a clean Mac

In the above procedure, I added the Python3 path to / usr / bin / python. You can now pass the aws command safely.

Miscellaneous feelings

To be honest, I thought I should have reinstalled it from the beginning. I thought it would be troublesome to reset the interpreter in the IDE, but it's quite short compared to the time I was addicted to.

It's important to give up everything ...

Recommended Posts

I get a Python No module named'encodings' error with the aws command
Error when installing a module with Python pip
[Python] Get the files in a folder with Python
I get an OS Error: [Errno 8] Exec format error when running a Flask application with a python command
A memo that I touched the Datastore with python
When I try to import pandas on macOS I get the error No module named'_bz2'
I replaced the Windows PowerShell cookbook with a python script.
Why can I use the module by importing with python?
Minimum knowledge to get started with the Python logging module
A story about a python beginner stuck with No module named'http.server'
Python error: ModuleNotFoundError: No module named'flask'
Get the weather with Python requests
Get the weather with Python requests 2
I made a class to get the analysis result by MeCab in ndarray with python
I made a fortune with Python.
I liked the tweet with python. ..
I made a daemon with Python
[Python] A memo that I tried to get started with asyncio
I wanted to solve the ABC164 A ~ D problem with Python
The story of making a module that skips mail with python
Create a compatibility judgment program with the random module of python.
A story that didn't work when I tried to log in with the Python requests module
I get an error with import pandas.
Today's python error: ModuleNotFoundError: No module named
Suddenly with Python PyInstaller No module named pyinstaller
Today's python error: ModuleNotFoundError: No module named
I made a character counter with Python
[Python] Get the variable name with str
Search the maze with the python A * algorithm
When I get an error with PyInstaller
I want to play with aws with python
I tried a functional language with Python
What I did with a Python array
Today's python error: ModuleNotFoundError: No module named'requests'
I made a Hex map with Python
I made a roguelike game with Python
Today's python error: ModuleNotFoundError: No module named'bs4'
I made a simple blackjack with Python
I made a configuration file with Python
Import Error in Python3: No module named'xxxxx'
I made a neuron simulator with Python
Get the number of searches with a regular expression. SeleniumBasic VBA Python
I tried to get the authentication code of Qiita API with Python.
I get a UnicodeDecodeError when trying to connect to oracle with python sqlalchemy
Install the python module with pip on a server without root privileges
[Python, ObsPy] I drew a beach ball on the map with Cartopy + ObsPy.
Create a record with attachments in KINTONE using the Python requests module
I tried to get the movie information of TMDb API with Python
If you get a no attribute error in boto3, check the version
I made a module PyNanaco that can charge nanaco credit with python
Use AWS interpreter with Pycharm
I want to use only the SMTP MAIL FROM command and RCPT TO command without sending mail with Python's smtplib
Use the preview feature with aws-cli
Using cgo with the go command
Hit the top command with htop
I get a Python No module named'encodings' error with the aws command
When I import TensorFlow to Python, I get "Import Error: DLL load failed: The specified module cannot be found."
I get an error when I put a Python plugin in Visual Studio Code under the pyenv environment
After installing Anaconda3, I get the error "zsh: no such file or directory:/opt/anaconda3/bin/conda" in the command line preferences.
I tried "smoothing" the image with Python + OpenCV
When I get a chromedriver error in Selenium
Get the latest AMI information with the AWS CLI
I made a competitive programming glossary with Python
I made a weather forecast bot-like with Python.
I made a GUI application with Python + PyQt5
In the Chainer tutorial, I get an error when importing a package. (mock)