Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AWS CLI upload failed: unknown encoding: idna

I am trying to push some files up to s3 with the AWS CLI and I am running into an error:

upload failed: ... An HTTP Client raised and unhandled exception: unknown encoding: idna

I believe this is a Python specific problem but I am not sure how to enable this type of encoding for my python interpreter. I just freshly installed Python 3.6 and have verified that it being used by powershell and cmd.

$> python --version Python 3.6.7

If this isn't a Python specific problem, it might be helpful to know that I also just freshly installed the AWS CLI and have it properly configured. Let me know if there is anything else I am missing to help solve this problem. Thanks.

like image 677
Justin Avatar asked Nov 04 '18 18:11

Justin


3 Answers

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

like image 153
Djidiouf Avatar answered Nov 15 '22 05:11

Djidiouf


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

like image 22
Vereb Avatar answered Nov 15 '22 03:11

Vereb


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.

like image 8
progm Avatar answered Nov 15 '22 03:11

progm