Windows locale error unsupported locale setting

Why do I get the following error when doing this in python: >>> import locale >>> print str( locale.getlocale() ) (None, None) >>> locale.setlocale(locale.LC_ALL, 'de_DE')

In trying to get python to spit out names in specific locale I landed here with same problem.

In pursuing the answer, things got a little mystical I find.

I found that python code.

import locale
print locale.getdefaultlocale()
>> ('en_DK', 'UTF-8')

And indeed locale.setlocale(locale.LC_TIME, 'en_DK.UTF-8') works

Using tips here I tested further to see what is available using python code

import locale
loc_list = [(a,b) for a,b in locale.locale_alias.items() ]
loc_size = len(loc_list)
print loc_size,'entries'

for loc in loc_list:
    try:
        locale.setlocale(locale.LC_TIME, loc[1])
        print 'SUCCES set {:12} ({})'.format(loc[1],loc[0])
    except:
        pass

which yields

858 entries
SUCCES set en_US.UTF-8  (univ)
SUCCES set C            (c.ascii)
SUCCES set C            (c.en)
SUCCES set C            (posix-utf2)
SUCCES set C            (c)
SUCCES set C            (c_c)
SUCCES set C            (c_c.c)
SUCCES set en_IE.UTF-8  (en_ie.utf8@euro)
SUCCES set en_US.UTF-8  (universal.utf8@ucs4)
SUCCES set C            (posix)
SUCCES set C            (english_united-states.437)
SUCCES set en_US.UTF-8  (universal)

Of which only above is working! But the en_DK.UTF-8 is not in this list, though it works!?!? What??
And the python generated locale list do contain a lot of combos of da and DK, which I am looking for, but again no UTF-8 for da/DK…

I am on a Point Linux distro (Debian based), and here locale says amongst other LC_TIME="en_DK.UTF-8", which I know works, but not the locale I need.

locale -a says

C
C.UTF-8
en_DK.utf8
en_US.utf8
POSIX

So definitely need to install other locale, which i did by editing /etc/locale.gen, uncomment needed line da_DK.UTF-8 UTF-8 and run command locale-gen

Now locale.setlocale(locale.LC_TIME, 'da_DK.UTF-8') works too, and I can get my localized day and month names.

My Conclision:

Python : locale.locale_alias is not at all helpfull in finding available locales!!!

Linux : It is quite easy to get locale list and install new locale. A lot of help available.

Windows : I have been investigating a little, but nothing conclusive. There are though posts leading to answers, but I have not felt the urge to pursue it.

  1. What Is the Locale Module in Python
  2. What Is the locale.Error: unsupported locale setting in Python
  3. How to Fix the locale.Error: unsupported locale setting in Python
  4. Fix the locale.Error: unsupported locale setting With the export Command
  5. Fix the locale.Error: unsupported locale setting From Your Terminal
  6. Enlist All the Available Languages in the Locale Module

Locale.Error: Unsupported Locale Setting in Python

Python is a diverse and powerful programming language with many libraries and frameworks that allow you to achieve the desired tasks efficiently.

Regarding taking care of developers, Python is always on the top. Here is one of the famous modules to help developers generalize the software without facing any cultural barriers, and that module is Locale.

What Is the Locale Module in Python

As discussed, the locale module is developed to facilitate the developers to deal with certain cultural issues in the software.

So let’s explore the Locale module and try to fix one of the most common errors, locale.Error: unsupported locale setting you will encounter when you are new to this module.

Before going into the details of the error, let’s see what the locale module is, how to import it, and what else is required in this module.

Code example:

import locale

# get the current locale
print(locale.getlocale())

Output:

('English_United States', '1252')

We have English_United States.1252 as the preferred locale in our case; basically, it depends on the settings; you might have a different preferred locale on your machines.

But you can change the default locale into your preferred locale from the available list with the help of the setlocale() function.

locale.setlocale(locale.LC_ALL, 'German')

Output:

What Is the locale.Error: unsupported locale setting in Python

In Python, when you are new to the locale module, you might encounter the locale.Error: unsupported locale setting at some point. And the reasons behind that you didn’t have either properly installed the locale module or issues with the parameters you are providing.

Let’s see an example to understand the locale.Error: unsupported locale setting in a better way.

import locale
print(str(locale.getlocale()))
locale.setlocale(locale.LC_ALL, 'de_DE')

Output:

locale.Error: unsupported locale setting

And the core reason behind this error is that your environment variable LC_ALL is missing or invalid. In this case, de_DE is missing, so you get the error locale.Error: unsupported locale setting.

How to Fix the locale.Error: unsupported locale setting in Python

As we have seen in the above code, it has caused the locale error, and the reason was we were missing the environment variables, or the provided one was invalid. And to fix that, there are multiple solutions; each is explained one by one, so make sure to check out each to fix the locale.Error: unsupported locale setting.

Let’s begin with setting the environment variables. To do so, go to your terminal and type the following commands.

Fix the locale.Error: unsupported locale setting With the export Command

export LC_ALL="en_US.UTF-8"
export LC_CTYPE="en_US.UTF-8"
sudo dpkg-reconfigure locales

You can also do it in one line of code. Both work the same.

export LC_ALL="en_US.UTF-8" & export LC_CTYPE="en_US.UTF-8" & sudo dpkg-reconfigure locales

In the above commands, the LC_ALL and LC_CTYPE are used to set the environment variables, and the last command sudo dpkg-reconfigure locales is used to commit the changes into the system.

Fix the locale.Error: unsupported locale setting From Your Terminal

If that didn’t work for you, you could try to reinstall locale from your terminal.

sudo apt-get install locales -y

The above command will install locale. Now generate a list of locales with the locale-gen command.

sudo locale-gen en_US.UTF-8

And finally, set the configuration permanently to the system.

sudo echo "LANG=en_US.UTF-8" > /etc/default/locale

Running the above commands might ask you to restart your machine; you should allow it to restart.

Enlist All the Available Languages in the Locale Module

You can run the below command or the Python program to verify that the given locale exists in the locale list.

Below is the Python program to see the list of available locales.

import locale
for language in locale.windows_locale.values():
    print(language, end =", ")

Output:

af_ZA, sq_AL, gsw_FR, am_ET, de_DE, de_CH, ....., sah_RU, ii_CN, yo_NG, zu_ZA

The above program will loop through the available list of locale languages and print each as shown in the output. Now you can pick anything available in the list and put it in the program to see its output, which should work properly.

Code Example:

import locale
print(str(locale.getlocale()))
locale.setlocale(locale.LC_ALL, 'de_DE')

Output:

('de_DE', 'UTF-8')
'de_DE'

Perfect! As you can see, it is working perfectly; we have set the locale language as de_DE as it’s running smoothly.

Remember de_DE exists in the list of the local languages, as shown in the above example, and it represents the German language.

Deepika Banoth

If you see the following error while installing pip:

Traceback (most recent call last):
     File "/usr/bin/pip", line 11, in <module>
       sys.exit(main())
     File "/usr/lib/python2.7/dist-packages/pip/__init__.py", line 215, in main
       locale.setlocale(locale.LC_ALL, '')
     File "/usr/lib/python2.7/locale.py", line 581, in setlocale
       return _setlocale(category, locale)
   locale.Error: unsupported locale setting

this means the environment variable LC_ALL is missing or invalid somehow.

FIX :

run the following command:

and retry installing again.

What is LC_ALL?

LC_ALL is the environment variable that overrides the value of the LANG and the values of any other LC_* environment variables.

In a script, if you want to force a specific setting, as you don’t know what settings the user has forced, your safest and generally only option is to force LC_ALL.

The C locale is for computers. In the C locale, characters are single bytes, the charset is ASCII, the sorting order is based on the byte values, the language is usually US English.
You generally run a command with LC_ALL=C to avoid the user’s settings to interfere with your script. For example, if you want [a-z] to match the 26 ASCII characters from a to z, you have to set LC_ALL=C.

Hope this helps! :)

hi @LoveBootCaptain ,
i saw your project by twitter, and at the same i see this project here.i’m a beginner in python,too. So i try to build this project. And i encounter an error:

Traceback (most recent call last):
  File "C:UsersAdministratorDesktopWeatherPi_TFT-masterWeatherPi_TFT.py", line 16, in <module>
    locale.setlocale(locale.LC_ALL, locale.getdefaultlocale())
  File "D:Python35liblocale.py", line 594, in setlocale
    return _setlocale(category, locale)
locale.Error: unsupported locale setting

i dont know where is wrong.However,i annotate return _setlocale(category, locale) in «D:Python35liblocale.py», line 594
and the error is gone
But there is a new error:

Traceback (most recent call last):
  File "C:UsersAdministratorDesktopWeatherPi_TFT-masterWeatherPi_TFT.py", line 637, in <module>
    loop()
  File "C:UsersAdministratorDesktopWeatherPi_TFT-masterWeatherPi_TFT.py", line 602, in loop
    Update.run()
  File "C:UsersAdministratorDesktopWeatherPi_TFT-masterWeatherPi_TFT.py", line 410, in run
    Update.update_json()
  File "C:UsersAdministratorDesktopWeatherPi_TFT-masterWeatherPi_TFT.py", line 212, in update_json
    config = json.loads(config_data)
  File "D:Python35libjson__init__.py", line 319, in loads
    return _default_decoder.decode(s)
  File "D:Python35libjsondecoder.py", line 339, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "D:Python35libjsondecoder.py", line 355, in raw_decode
    obj, end = self.scan_once(s, idx)
json.decoder.JSONDecodeError: Expecting property name enclosed in double quotes: line 3 column 1 (char 59)

i have no idea about it…

PS: i can get defaultlocale by locale.getdefaultlocale():

>>> locale.getdefaultlocale()
('zh_CN', 'cp936')

Do you have a idea?

Python is a popular general purpose programming language that can be used to serve many different use cases. Created by Guido van Rossum with the name inspired from British comedy show Monty Python, it was set out to be straightforward and easy-to-use, emphasized in wp-block-code readability. Python 3 is the latest version of the language and is considered to be the future of Python.

The set up of Python 3 on your Linux machine should be straightforward without any error, but sometimes you will encounter locale.Error: unsupported locale setting – one of the most common problem of Python. This tutorial will show you how to fix it explicitly on Ubuntu 18.04, but the process remains the same for other distro.

When does locale.Error happens?

The root cause is: your environment variable LC_ALL is missing or invalid somehow

➜ ~ pip install virtualenv Traceback (most recent call last): File "/usr/bin/pip", line 11, in <module> sys.exit(main()) File "/usr/lib/python3.4/site-packages/pip/__init__.py", line 215, in main locale.setlocale(locale.LC_ALL, '') File "/usr/lib64/python3.4/locale.py", line 592, in setlocale return _setlocale(category, locale) locale.Error: unsupported locale setting

Code language: Bash (bash)

locale.Error could be triggered when you :

  • Using pip to install a package that make use of locale package on a newly installed machine
  • Using virtualenv to make a new virtual environment
  • You’ve been fiddling with the environment variables then try to use pip
  • Running programs built with Python for the first time after fresh OS installation.
  • Sometimes it happens with programs like ssh, a2enmod, and perl programs too.

If you want to solve it quick, you can sequentially run the commands below in the terminal :

export LC_ALL="en_US.UTF-8" export LC_CTYPE="en_US.UTF-8" sudo dpkg-reconfigure locales

Code language: Bash (bash)

The first two commands set the LC_ALL and LC_CTYPE environment variables, then the third one commits the changes to the system. After running these, a few command-line style window could probably pop up, you can just hit OK until it’s done, there is pretty much nothing to configure.

Here is a one-liner for you the lazy guys :

export LC_ALL="en_US.UTF-8" & export LC_CTYPE="en_US.UTF-8" & sudo dpkg-reconfigure locales

Code language: Bash (bash)

The output should look like this :

~$ export LC_ALL="en_US.UTF-8" & export LC_CTYPE="en_US.UTF-8" & sudo dpkg-reconfigure locales [1] 7201 [2] 7202 [sudo] password for user: Generating locales (this might take a while)... en_AG.UTF-8... done en_AU.UTF-8... done en_BW.UTF-8... done en_CA.UTF-8... done en_DK.UTF-8... done en_GB.UTF-8... done en_HK.UTF-8... done en_IE.UTF-8... done en_IL.UTF-8... done en_IN.UTF-8... done en_NG.UTF-8... done en_NZ.UTF-8... done en_PH.UTF-8... done en_SG.UTF-8... done en_US.UTF-8... done en_ZA.UTF-8... done en_ZM.UTF-8... done en_ZW.UTF-8... done vi_VN.UTF-8... done Generation complete. [1]- Done export LC_ALL="en_US.UTF-8" [2]+ Done export LC_CTYPE="en_US.UTF-8"

Code language: Bash (bash)

Fix locale.Error permanently

While you can set the locale exporting an environment variable, you will have to do that every time you start a session, meaning after a restart, things would go back the same as before. Setting a locale the following way will solve the problem permanently.

First, you need to install locales package :

sudo apt-get install locales -y

Code language: Bash (bash)

Then use the locale-gen command to generate locales :

sudo locale-gen en_US.UTF-8

Code language: Bash (bash)

After that, permanently set the configuration to the system

sudo echo "LANG=en_US.UTF-8" > /etc/default/locale

Code language: Bash (bash)

You might also need to restart your system for changes to take effect.

Fix locale.Error for Docker

Just add these lines to your Dockerfile

Dockerfile# Set the locale RUN locale-gen en_US.UTF-8 ENV LANG en_US.UTF-8 ENV LANGUAGE en_US:en ENV LC_ALL en_US.UTF-8

Code language: Dockerfile (dockerfile)

After setting the locale, verify that the system is updated by using the following command :

~$ locale LANG=en_US.UTF-8 LANGUAGE= LC_CTYPE="en_US.UTF-8" LC_NUMERIC="en_US.UTF-8" LC_TIME="en_US.UTF-8" LC_COLLATE="en_US.UTF-8" LC_MONETARY="en_US.UTF-8" LC_MESSAGES="en_US.UTF-8" LC_PAPER="en_US.UTF-8" LC_NAME="en_US.UTF-8" LC_ADDRESS="en_US.UTF-8" LC_TELEPHONE="en_US.UTF-8" LC_MEASUREMENT="en_US.UTF-8" LC_IDENTIFICATION="en_US.UTF-8" LC_ALL=en_US.UTF-8

Code language: Bash (bash)

FAQ

How to fix locale.Error: unsupported locale setting quickly?

Open up Terminal app and enter this command (without the single quote)
‘export LC_ALL=”en_US.UTF-8″ & export LC_CTYPE=”en_US.UTF-8″ & sudo dpkg-reconfigure locales’

Why does locale.Error happens?

Invalid or missing LC_ALL system variable

How to fix locale.Error once and for all?

Install locales package : sudo apt-get install locales -y
Then, generate locales : sudo locale-gen en_US.UTF-8
Finally, write it to system configuration : sudo echo “LANG=en_US.UTF-8” > /etc/default/locale

Answer by Calum Campbell

This error can occur, if you have just added a new locale. You need to restart the python interactive shell (quit() and python) to get access to it.,To install a new locale use:,This file can either be adjusted manually or updated using the tool, update-locale.,run locale-gen to generate newly added locales

Run following commands

export LC_ALL="en_US.UTF-8"
export LC_CTYPE="en_US.UTF-8"
sudo dpkg-reconfigure locales

Answer by Layton Dodson

While you can set the locale exporting an environment variable, you will have to do that every time you start a session, meaning after a restart, things would go back the same as before. Setting a locale the following way will solve the problem permanently.,You’ve been fiddling with the environment variables then try to use pip,The root cause is: your environment variable LC_ALL is missing or invalid somehow,If you want to solve it quick, you can sequentially run the commands below in the terminal :

The root cause is: your environment variable LC_ALL is missing or invalid somehow

.wp-block-code{border:0;padding:0}.wp-block-code>div{overflow:auto}.shcb-language{border:0;clip:rect(1px,1px,1px,1px);-webkit-clip-path:inset(50%);clip-path:inset(50%);height:1px;margin:-1px;overflow:hidden;padding:0;position:absolute;width:1px;word-wrap:normal;word-break:normal}.hljs{box-sizing:border-box}.hljs.shcb-code-table{display:table;width:100%}.hljs.shcb-code-table>.shcb-loc{color:inherit;display:table-row;width:100%}.hljs.shcb-code-table .shcb-loc>span{display:table-cell}.wp-block-code code.hljs:not(.shcb-wrap-lines){white-space:pre}.wp-block-code code.hljs.shcb-wrap-lines{white-space:pre-wrap}.hljs.shcb-line-numbers{border-spacing:0;counter-reset:line}.hljs.shcb-line-numbers>.shcb-loc{counter-increment:line}.hljs.shcb-line-numbers .shcb-loc>span{padding-left:.75em}.hljs.shcb-line-numbers .shcb-loc::before{border-right:1px solid #ddd;content:counter(line);display:table-cell;padding:0 .75em;text-align:right;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;white-space:nowrap;width:1%}➜  ~ pip install virtualenv
Traceback (most recent call last):
  File "/usr/bin/pip", line 11, in <module>
    sys.exit(main())
  File "/usr/lib/python3.4/site-packages/pip/__init__.py", line 215, in main
    locale.setlocale(locale.LC_ALL, '')
  File "/usr/lib64/python3.4/locale.py", line 592, in setlocale
    return _setlocale(category, locale)
locale.Error: unsupported locale setting
Code language: Bash (bash)

If you want to solve it quick, you can sequentially run the commands below in the terminal :

export LC_ALL="en_US.UTF-8"
export LC_CTYPE="en_US.UTF-8"
sudo dpkg-reconfigure localesCode language: Bash (bash)

Here is a one-liner for you the lazy guys :

export LC_ALL="en_US.UTF-8" & export LC_CTYPE="en_US.UTF-8" & sudo dpkg-reconfigure localesCode language: Bash (bash)

The output should look like this :

~$ export LC_ALL="en_US.UTF-8" & export LC_CTYPE="en_US.UTF-8" & sudo dpkg-reconfigure locales

[1] 7201
[2] 7202
[sudo] password for user: 
Generating locales (this might take a while)...
  en_AG.UTF-8... done
  en_AU.UTF-8... done
  en_BW.UTF-8... done
  en_CA.UTF-8... done
  en_DK.UTF-8... done
  en_GB.UTF-8... done
  en_HK.UTF-8... done
  en_IE.UTF-8... done
  en_IL.UTF-8... done
  en_IN.UTF-8... done
  en_NG.UTF-8... done
  en_NZ.UTF-8... done
  en_PH.UTF-8... done
  en_SG.UTF-8... done
  en_US.UTF-8... done
  en_ZA.UTF-8... done
  en_ZM.UTF-8... done
  en_ZW.UTF-8... done
  vi_VN.UTF-8... done
Generation complete.
[1]-  Done                    export LC_ALL="en_US.UTF-8"
[2]+  Done                    export LC_CTYPE="en_US.UTF-8"
Code language: Bash (bash)

First, you need to install locales package :

sudo apt-get install locales -yCode language: Bash (bash)

Then use the locale-gen command to generate locales :

sudo locale-gen en_US.UTF-8Code language: Bash (bash)

After that, permanently set the configuration to the system

sudo echo "LANG=en_US.UTF-8" > /etc/default/localeCode language: Bash (bash)

Just add these lines to your Dockerfile

Dockerfile#
Set the locale
RUN locale-gen en_US.UTF-8
ENV LANG en_US.UTF-8
ENV LANGUAGE en_US:en
ENV LC_ALL en_US.UTF-8
Code language: Dockerfile (dockerfile)

After setting the locale, verify that the system is updated by using the following command :

~$ locale

LANG=en_US.UTF-8
LANGUAGE=
LC_CTYPE="en_US.UTF-8"
LC_NUMERIC="en_US.UTF-8"
LC_TIME="en_US.UTF-8"                                                                                                                                                            
LC_COLLATE="en_US.UTF-8"                                                                                                                                                         
LC_MONETARY="en_US.UTF-8"                                                                                                                                                        
LC_MESSAGES="en_US.UTF-8"
LC_PAPER="en_US.UTF-8"
LC_NAME="en_US.UTF-8"
LC_ADDRESS="en_US.UTF-8"
LC_TELEPHONE="en_US.UTF-8"
LC_MEASUREMENT="en_US.UTF-8"
LC_IDENTIFICATION="en_US.UTF-8"
LC_ALL=en_US.UTF-8
Code language: Bash (bash)

Answer by Amaris Lozano

this means the environment variable LC_ALL is missing or invalid somehow.,LC_ALL is the environment variable that overrides the value of the LANG and the values of any other LC_* environment variables.,If you see the following error while installing pip:
,well explained.. it overrides all the other localisation settings.

Traceback (most recent call last):
     File "/usr/bin/pip", line 11, in <module>
       sys.exit(main())
     File "/usr/lib/python2.7/dist-packages/pip/__init__.py", line 215, in main
       locale.setlocale(locale.LC_ALL, '')
     File "/usr/lib/python2.7/locale.py", line 581, in setlocale
       return _setlocale(category, locale)
   locale.Error: unsupported locale setting

Answer by Noor Correa

Ok, so I’ve just encountered the following error on my newly installed Ubuntu Machine: locale.Error: unsupported locale setting when I was trying create a virtual environment with python-virtualenv. After some googling i found the following solution:,Digital Designer, Backend and Frontend developer from Sweden with experience in usability.

Ok, so I’ve just encountered the following error on my newly installed Ubuntu Machine: locale.Error: unsupported locale setting when I was trying create a virtual environment with python-virtualenv. After some googling i found the following solution:

export LANGUAGE=en_US.UTF-8export LANG=en_US.UTF-8export LC_ALL=en_US.UTF-8locale-gen en_US.UTF-8sudo dpkg-reconfigure locales

Answer by Otis Bonilla

The reason is that the system lacks the corresponding language package, which needs to be downloaded and installed.,locale.Error: unsupported locale setting locale,Error: the solution set by unsupported locale
0. References 1. Cause of error 2. Solution,0. References
https://stackoverflow.com/questions/14547631/python-locale-error-unsupported-locale-setting

1. Report the cause of the error
The ubuntu 16.04 installed on the vagrant + virtualbox installed on the ubuntu 16.04 used the pip3 list and the python3-m venv venv both commands gave the error message as follows:

[email protected]:~/microblog$ pip3 list
Traceback (most recent call last):
  File "/usr/bin/pip3", line 11, in <module>
    sys.exit(main())
  File "/usr/lib/python3/dist-packages/pip/__init__.py", line 215, in main
    locale.setlocale(locale.LC_ALL, '')
  File "/usr/lib/python3.5/locale.py", line 594, in setlocale
    return _setlocale(category, locale)
locale.Error: unsupported locale setting

2. Solutions
Use the locale locale to view the current language Settings:

[email protected]:~$ locale
locale: Cannot set LC_ALL to default locale: No such file or directory
LANG=en_US.UTF-8
LANGUAGE=
LC_CTYPE="en_US.UTF-8"
LC_NUMERIC=zh_CN.UTF-8
LC_TIME=zh_CN.UTF-8
LC_COLLATE="en_US.UTF-8"
LC_MONETARY=zh_CN.UTF-8
LC_MESSAGES="en_US.UTF-8"
LC_PAPER=zh_CN.UTF-8
LC_NAME=zh_CN.UTF-8
LC_ADDRESS=zh_CN.UTF-8
LC_TELEPHONE=zh_CN.UTF-8
LC_MEASUREMENT=zh_CN.UTF-8
LC_IDENTIFICATION=zh_CN.UTF-8
LC_ALL=

It is found that there are two languages in this setting, one is en_us.utf-8 , and the other is zh_cn.utf-8 .
Use locale -a to view all available languages in the current system:

[email protected]:~$ locale -a
C
C.UTF-8
en_US.utf8
id_ID.utf8
POSIX

It was found that zh_cn.utf-8 is missing in the available language above, and this is the reason for the error.
Use sudo apt install language-pack-zh-hans installation language:

[email protected]:~$ sudo apt install language-pack-zh-hans
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following additional packages will be installed:
  language-pack-zh-hans-base
The following NEW packages will be installed:
  language-pack-zh-hans language-pack-zh-hans-base
0 upgraded, 2 newly installed, 0 to remove and 3 not upgraded.
Need to get 2110 kB of archives.
After this operation, 8545 kB of additional disk space will be used.
Do you want to continue?[Y/n] y
Get:1 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 language-pack-zh-hans-base all 1:16.04+20160627 [2108 kB]
Get:2 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 language-pack-zh-hans all 1:16.04+20160627 [1870 B]
Fetched 2110 kB in 3s (567 kB/s)           
perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
    LANGUAGE = (unset),
    LC_ALL = (unset),
    LC_TIME = "zh_CN.UTF-8",
    LC_MONETARY = "zh_CN.UTF-8",
    LC_ADDRESS = "zh_CN.UTF-8",
    LC_TELEPHONE = "zh_CN.UTF-8",
    LC_NAME = "zh_CN.UTF-8",
    LC_MEASUREMENT = "zh_CN.UTF-8",
    LC_IDENTIFICATION = "zh_CN.UTF-8",
    LC_NUMERIC = "zh_CN.UTF-8",
    LC_PAPER = "zh_CN.UTF-8",
    LANG = "en_US.UTF-8"
    are supported and installed on your system.
perl: warning: Falling back to a fallback locale ("en_US.UTF-8").
locale: Cannot set LC_ALL to default locale: No such file or directory
Selecting previously unselected package language-pack-zh-hans-base.
(Reading database ... 89747 files and directories currently installed.)
Preparing to unpack .../language-pack-zh-hans-base_1%3a16.04+20160627_all.deb ...
Unpacking language-pack-zh-hans-base (1:16.04+20160627) ...
Selecting previously unselected package language-pack-zh-hans.
Preparing to unpack .../language-pack-zh-hans_1%3a16.04+20160627_all.deb ...
Unpacking language-pack-zh-hans (1:16.04+20160627) ...
Setting up language-pack-zh-hans (1:16.04+20160627) ...
Setting up language-pack-zh-hans-base (1:16.04+20160627) ...
Generating locales (this might take a while)...
  zh_CN.UTF-8... done
  zh_SG.UTF-8... done
Generation complete.

Answer by Drew Knight

Note that this function will not work with the ‘C’ locale, so you have to set a
locale via setlocale() first.,If the given encoding is not known, the function defaults to the default
encoding for the locale code just like setlocale().,The locale module defines the following exception and functions:,If locale is omitted or None, the current setting for category is
returned.

import locale
locale.setlocale(locale.LC_ALL, '')

Answer by Nathanael Velazquez

I’m new to python and getting this following error. FYI, I’m from India so, is there any issue in Indian Date Format?,Doing some testing now. Thanks for the logs @bobpullen,

Sorry, something went wrong.
,Try this simple python program, does it also give you an error:

import locale

locale.setlocale(locale.LC_ALL, 'en_GB')

0 / 0 / 0

Регистрация: 26.11.2019

Сообщений: 4

1

01.07.2020, 13:57. Показов 4419. Ответов 1


При импорте locale. И вызове locale.setlocale(locale.LC_ALL,’ru_RU.UTF-8′) — возникает ошибка locale.Error: unsupported locale setting. Подскажите, как исправить или в чем проблема

Locale.Error: unsupported locale setting

__________________
Помощь в написании контрольных, курсовых и дипломных работ, диссертаций здесь



0



0 / 0 / 0

Регистрация: 26.11.2019

Сообщений: 4

01.07.2020, 15:14

 [ТС]

2

Ошибка найдена, нужно писать ‘ru-Ru’, вместо ‘ru_RU’



0



IT_Exp

Эксперт

87844 / 49110 / 22898

Регистрация: 17.06.2006

Сообщений: 92,604

01.07.2020, 15:14

Помогаю со студенческими работами здесь

Locale
Всем доброго времени суток!У меня вопрос,как в языке Си добиться того,чтобы консоль читала русские…

локаль(locale)
int main() {
std::locale::global(std::locale(&quot;rus&quot;));

//std::cout.imbue(std::locale(&quot;rus&quot;));…

Locale Самтайма
Уважаемые гуру! Подскажите, пожалуйста, как изменить Locale самтайма на ru ? Пробовал в…

Std::locale()
Где посмотреть перечень строк, которые используются в качестве входных данных для него?

GlassFish locale
Всем доброго времени суток
Пишу тестовое задание — смена локали
англ / немецкая работет норм…

Установка locale (той которой от с++)
Как это правильно сделать?
std::locale::global(std::locale(&quot;ru_RU.cp1251&quot;));
так получаю эксепшн….

Искать еще темы с ответами

Или воспользуйтесь поиском по форуму:

2

Ошибка locale.Error: unsupported locale setting.

Ошибка возникает в таком участке кода:

import locale
locale.setlocale(locale.LC_TIME, ‘ru_RU.UTF-8’)

return self.view_functions[rule.endpoint](**req.view_args)
File «/venv/lib/python3.8/site-packages/flask_login/utils.py», line 272, in decorated_view
return func(*args, **kwargs)
File «./app/portfolio/routes.py», line 97, in get_share_operations
operations = [x.serialize for x in query.all()]
File «./app/portfolio/routes.py», line 97, in operations = [x.serialize for x in query.all()]
File «./app/models.py», line 222, in serialize
locale.setlocale(locale.LC_TIME, ‘ru_RU.UTF-8’)
File «/usr/lib/python3.8/locale.py», line 608, in setlocale
return _setlocale(category, locale)
locale.Error: unsupported locale setting
[pid: 661|app: 0|req: 39/115] 81.5.123.13 () {56 vars in 1390 bytes} [Fri Oct 9 00:37:07 2020] GET /portfolio/get-share-operations/FormFactor%20Inc => generated 290 bytes in 11 msecs (HTTP/1.1 500) 3 headers in 113 bytes (1 switches on core 0)

Ошибка возникает, когда на сервере не установлена требуемая локаль. Подробнее как установить локаль на сервере.

#
11 лет, 4 месяца назад

Темы:

9

Сообщения:

30

Участник с: 11 июля 2011

Только установил Archlinux + Gnome 3
Возникают ошибки:

При запуске настроев AWN:

(process:1130): Gtk-WARNING **: Locale not supported by C library.
	Using the fallback 'C' locale.
** Message: pygobject_register_sinkfunc is deprecated (AwnOverlay)
Traceback (most recent call last):
  File "/usr/bin/awn-settings", line 53, in <module>
    from awnClass import awnPreferences, awnManager, awnLauncher, awnApplet, awnThemeCustomize, awnTaskManager
  File "/usr/share/avant-window-navigator/awn-settings/awnClass.py", line 62, in <module>
    defs.i18nize(globals())
  File "/usr/share/avant-window-navigator/awn-settings/awnDefs.py", line 127, in i18nize
    locale.setlocale(locale.LC_ALL, '')
  File "/usr/lib/python2.7/locale.py", line 531, in setlocale
    return _setlocale(category, locale)
locale.Error: unsupported locale setting

(process:1209): Gtk-WARNING **: Locale not supported by C library.
	Using the fallback 'C' locale.
** Message: pygobject_register_sinkfunc is deprecated (AwnOverlay)
Traceback (most recent call last):
  File "/usr/bin/awn-settings", line 53, in <module>
    from awnClass import awnPreferences, awnManager, awnLauncher, awnApplet, awnThemeCustomize, awnTaskManager
  File "/usr/share/avant-window-navigator/awn-settings/awnClass.py", line 62, in <module>
    defs.i18nize(globals())
  File "/usr/share/avant-window-navigator/awn-settings/awnDefs.py", line 127, in i18nize
    locale.setlocale(locale.LC_ALL, '')
  File "/usr/lib/python2.7/locale.py", line 531, in setlocale
    return _setlocale(category, locale)
locale.Error: unsupported locale setting

При запуске gedit

(process:1158): Gtk-WARNING **: Locale not supported by C library.
	Using the fallback 'C' locale.
** (gedit:1158): WARNING **: Error loading plugin: libhspell.so.0: cannot open shared object file: No such file or directory
** (gedit:1158): DEBUG: gtk-menubar.vala:47: map called

В /etc/locale.gen
раскомментировал свою локаль

Мои настройки:
rc.conf

LOCALE="uk_UA.UTF-8"
HARDWARECLOCK="localtime"
TIMEZONE=Europe/Kiev
KEYMAP=uk
CONSOLEFONT=
CONSOLEMAP=
USECOLOR="yes"

Как избавиться от ошибок? Почему они возникают?

sirocco

#
11 лет, 4 месяца назад

Темы:

29

Сообщения:

2501

Участник с: 25 июля 2007

Что показывает

$ locale -a

artemhp

#
11 лет, 4 месяца назад

Темы:

9

Сообщения:

30

Участник с: 11 июля 2011

locale -a
locale: Cannot set LC_CTYPE to default locale: No such file or directory
locale: Cannot set LC_MESSAGES to default locale: No such file or directory
locale: Cannot set LC_COLLATE to default locale: No such file or directory
C
POSIX
en_US
en_US.iso88591
en_US.utf8

Nebulosa

#
11 лет, 4 месяца назад

Nebulosa avatar

Темы:

9

Сообщения:

826

Участник с: 05 марта 2009

Добавьте еще украинскую локализацию.

https://wiki.archlinux.org/index.php/Be … locale.gen

vadik

#
11 лет, 4 месяца назад

Темы:

55

Сообщения:

5410

Участник с: 17 августа 2009

В /etc/locale.gen
раскомментировал свою локаль

Раскомментировать не достаточно. Нужно еще выполнить команду locale-gen.

Like this post? Please share to your friends:
  • Windows loading files при установке очень долго
  • Windows loader скачать бесплатно для windows 7 торрент
  • Windows management framework 4 for windows 7
  • Windows loader скачать бесплатно для windows 7 максимальная 64 bit
  • Windows malicious software removal tool x64 что это