anyscale / academy

Ray tutorials from Anyscale
https://anyscale.com
Apache License 2.0
586 stars 195 forks source link

unsupported locale setting in `setlocale(local.getlocale())` #12

Closed laxatives closed 4 years ago

laxatives commented 4 years ago

Set locale like locale.setlocale(locale.LC_ALL, locale.getlocale()) here fails using python3.6 from the pip installation.

Example:

import locale
import sys

print(locale.getlocale())
print(sys.version)
locale.setlocale(locale.LC_ALL, locale.getlocale())

Returns:

('en_US', 'UTF-8')
3.6.9 (default, Apr 18 2020, 01:56:04) 
[GCC 8.4.0]
---------------------------------------------------------------------------
Error                                     Traceback (most recent call last)
<ipython-input-18-e1d930bcc3dd> in <module>
      4 print(locale.getlocale())
      5 print(sys.version)
----> 6 locale.setlocale(locale.LC_ALL, locale.getlocale())

/code/venvs/venv/lib/python3.6/locale.py in setlocale(category, locale)
    596         # convert to string
    597         locale = normalize(_build_localename(locale))
--> 598     return _setlocale(category, locale)
    599 
    600 def resetlocale(category=LC_ALL):

Error: unsupported locale setting

Resolved from the docs suggestion to set like locale.setlocale(locale.LC_ALL, ''), but not sure if that has the same behavior. Could just require users not to use python3.6 in the README.

deanwampler commented 4 years ago

Sorry for the delay in replying. Did you find it worked with 3.7 or 3.8? It would be better to use a later release anyway. I'll update the README.

laxatives commented 4 years ago

Yes, this was resolved in 3.7, did not try in 3.8.

deanwampler commented 4 years ago

Closing this for now, as I'm deprecating 3.6 support...

ayooshkathuria commented 4 years ago

I had the same issue with 3.7.8 as well. I created the Conda environment using the environmnent.yml file provided in the repo.

It turns out the error for me was happening because my LC_ALL in my systems locale was undefined. It can be easily check by typing locale at the terminal. Here is how mine looked.

image

The solution to this was to reconfigure my locale so that the LC_ALL is set to C.

export LC_ALL=C
sudo dpkg-reconfigure locales

Just keep hitting enter and let it do it's thing.

This sets the LC_ALL to C. The code works nicely after this.