AWS CLI upload failed: unknown encoding: idna

I had the same problem in Windows.

After investigating the problem, I realized that the problem is in the aws-cli installed using the MSI installer (x64). After removing "AWS Command Line Interface" from the list of installed programs and installing aws-cli using pip, the problem was solved.

I also tried to install MSI installer x32 and the problem was missing.


As a workaround, put the following import statement into the aws-script.py file.

import encodings.idna

Full path on 32-bit version is c:\Program Files (x86)\Amazon\AWSCLI\bin\aws-script.py

Full path on 64-bit version is C:\Program Files\Amazon\AWSCLI\bin\aws-script.py

I found this solution for a similar issue in this answer


On Windows, this is probably an issue with the AWS-cli tools being installed using the MSI installer. It seems the best way to fix this issue is to use the aws-cli tools installed with python.

Prerequisites: Python3 and Pip3

Verify you have Python and Pip installed

C:\> python --version
Python 3.7.1
C:\> pip3 --version
pip 18.1 from c:\program files\python37\lib\site-packages\pip (python 3.7)

Uninstall the AWS-CLI tools MSI installer

Install the aws-cli tools with pip

C:\> pip3 install awscli

Check if aws-cli is in your path already ; if not, add it

C:\> where aws
C:\Program Files\Python37\Scripts\aws

If not, locate where the aws-cli tools are deployed and add the path to your PATH environment variable (can be set in Control panel > System > Advance system settings > Environment Variables...).

Below, common path of the deployed AWS cli tools:

Python 3 and pip3 – C:\Program Files\Python37\Scripts\

Python 3 and pip3 --user option on earlier versions of Windows – %USERPROFILE%\AppData\Local\Programs\Python\Python37\Scripts

Python 3 and pip3 --user option on Windows 10 – %USERPROFILE%\AppData\Roaming\Python\Python37\Scripts