awslabs / aws-shell

An integrated shell for working with the AWS CLI.
Apache License 2.0
7.15k stars 770 forks source link

Error on first run - ValueError: unknown locale: UTF-8 #133

Closed jatins closed 6 years ago

jatins commented 7 years ago

I just installed aws-shell on El-Capitan (10.11.5), and getting this error:

First run, creating autocomplete index...
Traceback (most recent call last):
  File "/usr/local/bin/aws-shell", line 9, in <module>
    load_entry_point('aws-shell==0.1.1', 'console_scripts', 'aws-shell')()
  File "/Library/Python/2.7/site-packages/awsshell/__init__.py", line 43, in main
    from awsshell.makeindex import write_index
  File "/Library/Python/2.7/site-packages/awsshell/makeindex.py", line 7, in <module>
    from docutils.core import publish_string
  File "/Library/Python/2.7/site-packages/docutils/core.py", line 20, in <module>
    from docutils import frontend, io, utils, readers, writers
  File "/Library/Python/2.7/site-packages/docutils/frontend.py", line 41, in <module>
    import docutils.utils
  File "/Library/Python/2.7/site-packages/docutils/utils/__init__.py", line 20, in <module>
    import docutils.io
  File "/Library/Python/2.7/site-packages/docutils/io.py", line 18, in <module>
    from docutils.utils.error_reporting import locale_encoding, ErrorString, ErrorOutput
  File "/Library/Python/2.7/site-packages/docutils/utils/error_reporting.py", line 47, in <module>
    locale_encoding = locale.getlocale()[1] or locale.getdefaultlocale()[1]
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/locale.py", line 543, in getdefaultlocale
    return _parse_localename(localename)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/locale.py", line 475, in _parse_localename
    raise ValueError, 'unknown locale: %s' % localename
ValueError: unknown locale: UTF-8

Python version:

$ python --version          
Python 2.7.10
jatins commented 7 years ago

Found the solution here: http://stackoverflow.com/questions/22265659/trying-to-install-aws-cli-stuck-on-a-step

Still leaving this open, maybe it should give a more meaningful error if it expects those environment variables to be set?

donnemartin commented 7 years ago

This seems to be an issue affecting various Python projects. Here's a similar Stack Overflow post that points to a bug in Python.

There is an outstanding bug report related to this issue. It appears that Python makes some assumptions about the format of locale names that aren't universally valid. Explicitly setting these environment vars is basically just a workaround for that bug.

joguSD commented 6 years ago

Seeing as this is an upstream bug (potentially as far upstream as Python itself) and the only action we could take here is to re-throw a more meaningful error message I'm going to close this out. At least presently searching for the exact error that's being thrown now will easily lead you to the solution of setting those environment variables. Changing the error message might actually make it harder to find a solution.