问题:Python语言环境错误:不支持的语言环境设置

在python中执行此操作时为什么会出现以下错误:

>>> import locale
>>> print str( locale.getlocale() )
(None, None)
>>> locale.setlocale(locale.LC_ALL, 'de_DE')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python2.7/locale.py", line 531, in setlocale
    return _setlocale(category, locale)
locale.Error: unsupported locale setting

这也适用于其他语言环境,例如fr或nl。我正在使用Ubuntu 11.04。

更新:执行以下操作不会产生任何结果:

dpkg-reconfigure locales
perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
    LANGUAGE = (unset),
    LC_ALL = (unset),
    LC_CTYPE = "UTF-8",
    LANG = (unset)
    are supported and installed on your system.
perl: warning: Falling back to the standard locale ("C").
locale: Cannot set LC_CTYPE to default locale: No such file or directory
locale: Cannot set LC_ALL to default locale: No such file or directory

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')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python2.7/locale.py", line 531, in setlocale
    return _setlocale(category, locale)
locale.Error: unsupported locale setting

This works with other locales like fr or nl as well. I’m using Ubuntu 11.04.

Update: Doing the following did not yield anything:

dpkg-reconfigure locales
perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
    LANGUAGE = (unset),
    LC_ALL = (unset),
    LC_CTYPE = "UTF-8",
    LANG = (unset)
    are supported and installed on your system.
perl: warning: Falling back to the standard locale ("C").
locale: Cannot set LC_CTYPE to default locale: No such file or directory
locale: Cannot set LC_ALL to default locale: No such file or directory

回答 0

运行以下命令

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

它将解决此问题。

确保将.UTF-8部分与locale -a例如.utf8在某些系统上的输出中找到的实际语法匹配。

Run following commands

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

It will solve this.

Make sure to match the .UTF-8 part to the actual syntax found in the output of locale -a e.g. .utf8 on some systems.


回答 1

根据此链接,它通过输入以下命令来解决:

出口LC_ALL = C

According to this link, it solved by entering this command:

export LC_ALL=C


回答 2

您可能没有任何de_DE可用的语言环境。

您可以使用locale -a命令查看可用语言环境的列表。例如,在我的机器上:

$ locale -a
C
C.UTF-8
en_AG
en_AG.utf8
en_AU.utf8
en_BW.utf8
en_CA.utf8
en_DK.utf8
en_GB.utf8
en_HK.utf8
en_IE.utf8
en_IN
en_IN.utf8
en_NG
en_NG.utf8
en_NZ.utf8
en_PH.utf8
en_SG.utf8
en_US.utf8
en_ZA.utf8
en_ZM
en_ZM.utf8
en_ZW.utf8
it_CH.utf8
it_IT.utf8
POSIX

请注意,如果要将语言环境设置为,it_IT还必须指定.utf8

>>> import locale
>>> locale.setlocale(locale.LC_ALL, 'it_IT')   # error!
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python2.7/locale.py", line 539, in setlocale
    return _setlocale(category, locale)
locale.Error: unsupported locale setting
>>> locale.setlocale(locale.LC_ALL, 'it_IT.utf8')
'it_IT.utf8'

要安装新的语言环境,请使用:

sudo apt-get install language-pack-id

id语言代码在哪里(从此处获取

之后您已经安装了区域,那么你应该遵循朱利安Palard建议和重新配置的语言环境:

sudo dpkg-reconfigure locales

You probably do not have any de_DE locale available.

You can view a list of available locales with the locale -a command. For example, on my machine:

$ locale -a
C
C.UTF-8
en_AG
en_AG.utf8
en_AU.utf8
en_BW.utf8
en_CA.utf8
en_DK.utf8
en_GB.utf8
en_HK.utf8
en_IE.utf8
en_IN
en_IN.utf8
en_NG
en_NG.utf8
en_NZ.utf8
en_PH.utf8
en_SG.utf8
en_US.utf8
en_ZA.utf8
en_ZM
en_ZM.utf8
en_ZW.utf8
it_CH.utf8
it_IT.utf8
POSIX

Note that if you want to set the locale to it_IT you must also specify the .utf8:

>>> import locale
>>> locale.setlocale(locale.LC_ALL, 'it_IT')   # error!
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python2.7/locale.py", line 539, in setlocale
    return _setlocale(category, locale)
locale.Error: unsupported locale setting
>>> locale.setlocale(locale.LC_ALL, 'it_IT.utf8')
'it_IT.utf8'

To install a new locale use:

sudo apt-get install language-pack-id

where id is the language code (taken from here)

After you have installed the locale you should follow Julien Palard advice and reconfigure the locales with:

sudo dpkg-reconfigure locales

回答 3

上面的答案之一提供了解决方案:

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

上述解决方案的问题在于它必须在linux shell上完成。但是,如果您要提供在客户端计算机上工作的代码,那么这是一种不好的方法。我也尝试使用os.system()执行上述命令,但仍然无法正常工作。

对我有用的解决方案是

locale.setlocale(locale.LC_ALL,'en_US.UTF-8')

One of the above answer provides the solution:

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

The problem with above solution is that it has to be done on the linux shell. However, if you are providing your code to work on the client machine then this is a bad approach. I also tried executing the above commands using os.system(), but still it doesn’t work.

Solution that worked for me is

locale.setlocale(locale.LC_ALL,'en_US.UTF-8')

回答 4

更永久的解决方案是在命令显示的输出中填充缺少的值: locale

来自的输出locale是:

 $ locale
LANG=en_US.utf8
LANGUAGE=
LC_CTYPE="en_US.utf8"
LC_NUMERIC=es_ES.utf8
LC_TIME=es_ES.utf8
LC_COLLATE="en_US.utf8"
LC_MONETARY=es_ES.utf8
LC_MESSAGES="en_US.utf8"
LC_PAPER=es_ES.utf8
LC_NAME="en_US.utf8"
LC_ADDRESS="en_US.utf8"
LC_TELEPHONE="en_US.utf8"
LC_MEASUREMENT=es_ES.utf8
LC_IDENTIFICATION="en_US.utf8"
LC_ALL=

要填充缺少的值,请编辑〜/ .bashrc:

 $ vim ~/.bashrc

在上述命令之后添加以下行(假设您希望使用en_US.UTF-8作为您的语言):

export LANGUAGE="en_US.UTF-8"
export LC_ALL="en_US.UTF-8"

如果此文件为ReadOnly,则需要遵循The GeekyBoy提到的步骤。Beco博士在Superuser中给出的答案包含有关保存只读文件的详细信息。

保存文件后,请执行以下操作:

$ source ~/.bashrc

现在,您将不再面临相同的问题。

More permanent solution would be to fill the missing values, in the output shown by command: locale

Output from locale is:

 $ locale
LANG=en_US.utf8
LANGUAGE=
LC_CTYPE="en_US.utf8"
LC_NUMERIC=es_ES.utf8
LC_TIME=es_ES.utf8
LC_COLLATE="en_US.utf8"
LC_MONETARY=es_ES.utf8
LC_MESSAGES="en_US.utf8"
LC_PAPER=es_ES.utf8
LC_NAME="en_US.utf8"
LC_ADDRESS="en_US.utf8"
LC_TELEPHONE="en_US.utf8"
LC_MEASUREMENT=es_ES.utf8
LC_IDENTIFICATION="en_US.utf8"
LC_ALL=

To Fill the missing values edit ~/.bashrc :

 $ vim ~/.bashrc

Add the following lines after the above command (suppose you want en_US.UTF-8 to be your language):

export LANGUAGE="en_US.UTF-8"
export LC_ALL="en_US.UTF-8"

If this file is ReadOnly you would be needing to follow the steps mentioned by The GeekyBoy. The answer given by Dr Beco in Superuser has details relating to saving readonly files.

After saving the file do:

$ source ~/.bashrc

Now you wont be facing the same problem anymore.


回答 5

如果您使用的是Debian(或Debian分支),则可以使用来添加语言环境:

dpkg-reconfigure locales

If you’re on a Debian (or Debian fork), you can add locales using :

dpkg-reconfigure locales

回答 6

在Arch Linux上,我可以通过运行来解决此问题 sudo locale-gen

On Arch Linux I was able to fix this by running sudo locale-gen


回答 7

记录下来,我遇到了同样的问题,但是没有一种解决方案有效。我已经升级了计算机并迁移了PC。我有一个混合语言环境的英语和西班牙语:

$ locale
LANG=en_US.utf8
LANGUAGE=
LC_CTYPE="en_US.utf8"
LC_NUMERIC=es_ES.utf8
LC_TIME=es_ES.utf8
LC_COLLATE="en_US.utf8"
LC_MONETARY=es_ES.utf8
LC_MESSAGES="en_US.utf8"
LC_PAPER=es_ES.utf8
LC_NAME="en_US.utf8"
LC_ADDRESS="en_US.utf8"
LC_TELEPHONE="en_US.utf8"
LC_MEASUREMENT=es_ES.utf8
LC_IDENTIFICATION="en_US.utf8"
LC_ALL=

但是,在新的Debian安装中,我只是选择英语作为语言环境。最终可行的方法是重新配置语言环境包,以添加和生成西班牙语。

$ grep -v "#" /etc/locale.gen 
en_US.UTF-8 UTF-8
es_ES.UTF-8 UTF-8

For the record, I had this same problem, but none of the solutions worked. I had upgraded my computer and migrated my PC. I had a a mixed locale english and spanish:

$ locale
LANG=en_US.utf8
LANGUAGE=
LC_CTYPE="en_US.utf8"
LC_NUMERIC=es_ES.utf8
LC_TIME=es_ES.utf8
LC_COLLATE="en_US.utf8"
LC_MONETARY=es_ES.utf8
LC_MESSAGES="en_US.utf8"
LC_PAPER=es_ES.utf8
LC_NAME="en_US.utf8"
LC_ADDRESS="en_US.utf8"
LC_TELEPHONE="en_US.utf8"
LC_MEASUREMENT=es_ES.utf8
LC_IDENTIFICATION="en_US.utf8"
LC_ALL=

But, on my new Debian installation, I just selected english as locale. Which finally worked was to reconfigure locales package to add and generate spanish too.

$ grep -v "#" /etc/locale.gen 
en_US.UTF-8 UTF-8
es_ES.UTF-8 UTF-8

回答 8

只需打开.bashrc文件并将其添加

出口LC_ALL = C

然后在终端中键入source .bashrc。

Just open the .bashrc file and add this

export LC_ALL=C

and then type source .bashrc in terminal.


回答 9

您的错误清楚地表明,您正在尝试使用语言环境,但那里没有。

>>> locale.setlocale(locale.LC_ALL, 'de_DE')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python2.7/locale.py", line 581, in setlocale
    return _setlocale(category, locale)
locale.Error: unsupported locale setting

locale.Error:不支持的语言环境设置

要检查可用设置,请使用 locale -a

deb@deb-Latitude-E7470:/ambot$ locale -a
C
C.UTF-8
en_AG
en_AG.utf8
en_AU.utf8
en_BW.utf8
en_CA.utf8
en_DK.utf8
en_GB.utf8
en_HK.utf8
en_IE.utf8
en_IN
en_IN.utf8
en_NG
en_NG.utf8
en_NZ.utf8
en_PH.utf8
en_SG.utf8
en_US.utf8
en_ZA.utf8
en_ZM
en_ZM.utf8
en_ZW.utf8
POSIX

所以你可以在其中之一

>>> locale.setlocale(locale.LC_ALL, 'en_AG.utf8')
'en_AG.utf8'
>>> 

对于 de_DE

可以手动调整此文件,也可以使用工具update-locale更新该文件。

update-locale LANG=de_DE.UTF-8

You error clearly says, you are trying to use locale something was not there.

>>> locale.setlocale(locale.LC_ALL, 'de_DE')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python2.7/locale.py", line 581, in setlocale
    return _setlocale(category, locale)
locale.Error: unsupported locale setting

locale.Error: unsupported locale setting

To check available setting, use locale -a

deb@deb-Latitude-E7470:/ambot$ locale -a
C
C.UTF-8
en_AG
en_AG.utf8
en_AU.utf8
en_BW.utf8
en_CA.utf8
en_DK.utf8
en_GB.utf8
en_HK.utf8
en_IE.utf8
en_IN
en_IN.utf8
en_NG
en_NG.utf8
en_NZ.utf8
en_PH.utf8
en_SG.utf8
en_US.utf8
en_ZA.utf8
en_ZM
en_ZM.utf8
en_ZW.utf8
POSIX

so you can use one among,

>>> locale.setlocale(locale.LC_ALL, 'en_AG.utf8')
'en_AG.utf8'
>>> 

for de_DE

This file can either be adjusted manually or updated using the tool, update-locale.

update-locale LANG=de_DE.UTF-8

回答 10

  • 运行此命令 locale以获取使用的语言环境。如:

LANG = zh_CN.UTF-8
语言= zh_CN:zh_CN
LC_CTYPE = zh_CN.UTF-8
LC_NUMERIC =“ zh_CN.UTF-8”
LC_TIME =“ zh_CN.UTF-8”
LC_COLLATE =“ zh_CN.UTF-8”
LC_MONETARY =“ zh_CN .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 =“ zh_CN.UTF-8”
LC_IDENTIFICATION =“ zh_CN.UTF-8”
LC_ALL =

  • /etc/locale-gen文件的第一步中搜索列出的语言环境列表。对二手车不加评论
  • 运行locale-gen以生成新添加的语言环境
  • run this command locale to get what locale is used. Such as:

LANG=en_US.UTF-8
LANGUAGE=en_US:en
LC_CTYPE=zh_CN.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=

  • search for the listed locales list in first step in /etc/locale-gen file. Uncomment to used ones
  • run locale-gen to generate newly added locales

回答 11

我认为,在python {,3}中设置本地语言环境的最简单方法是:

>>> import locale
>>> locale.setlocale(locale.LC_ALL, '')
'de_DE.UTF-8'

然后,如果您使用的是不错的linux发行版,那么支持区域设置的东西就可以使用,并且也可以在其他OS的二进制发行版上使用(或者是恕我直言的错误)。

>>> import datetime as dt
>>> print(dt.date.today().strftime("%A %d. %B %Y"))
Sonntag 11. Dezember 2016

In my opinion, the easiest way to setup the local locale in python{,3} is:

>>> import locale
>>> locale.setlocale(locale.LC_ALL, '')
'de_DE.UTF-8'

Then, locale aware stuff just works, if you’re on a decent linux distro, and should work on binary distributions of the other OSes as well (or that’s a bug IMHO).

>>> import datetime as dt
>>> print(dt.date.today().strftime("%A %d. %B %Y"))
Sonntag 11. Dezember 2016

回答 12

将其放在Dockerfile上方ENV

# make the "en_US.UTF-8" locale so postgres will be utf-8 enabled by default
RUN apt-get update && apt-get install -y locales && rm -rf /var/lib/apt/lists/* \
    && localedef -i en_US -c -f UTF-8 -A /usr/share/locale/locale.alias en_US.UTF-8

ENV LANG en_US.UTF-8

Place it in the Dockerfile above the ENV.

# make the "en_US.UTF-8" locale so postgres will be utf-8 enabled by default
RUN apt-get update && apt-get install -y locales && rm -rf /var/lib/apt/lists/* \
    && localedef -i en_US -c -f UTF-8 -A /usr/share/locale/locale.alias en_US.UTF-8

ENV LANG en_US.UTF-8

回答 13

如果您刚刚添加了新的语言环境,则可能会发生此错误。您需要重新启动python交互式shell(quit()和python)才能访问它。

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.


回答 14

如果我是你,我将使用BABEL:http : //babel.pocoo.org/en/latest/index.html

我在使用Docker时遇到了同样的问题,我尝试了每个步骤,但都无法正常工作,总是出现区域设置错误,因此我决定使用BABEL,并且一切正常。

If I were you, I would use BABEL: http://babel.pocoo.org/en/latest/index.html

I got the same issue here using Docker, I’ve tried every single step and didn’t work well, always getting locale error, so I decided to use BABEL, and everything worked well.


回答 15

在尝试让python 在特定语言环境中吐出名称时,我遇到了同样的问题。

在寻找答案时,我发现事情有些神秘。

我发现了python代码。

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

确实locale.setlocale(locale.LC_TIME, 'en_DK.UTF-8')有效

我在这里使用提示进行了进一步测试,以查看使用python代码可以使用的技巧

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

产生

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)

其中只有上面的有效!但是en_DK.UTF-8,虽然可以使用,但不在此列表中!!!?什么??python生成的语言环境列表确实包含很多我想要的da和DK组合,但是同样没有da / DK的UTF-8。

我在Point Linux发行版(基于Debian)上,locale除其他外LC_TIME="en_DK.UTF-8",这里说的是我知道的,但我不需要的语言环境。

locale -a

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

因此,绝对需要安装其他语言环境,这是我通过编辑完成的/etc/locale.gen,取消注释了所需的行da_DK.UTF-8 UTF-8并运行命令locale-gen

现在locale.setlocale(locale.LC_TIME, 'da_DK.UTF-8')也可以使用,我可以获得本地化的日期和月份名称。

我的自负:

Python:locale.locale_alias根本对查找可用的语言环境没有帮助!

Linux:获取语言环境列表和安装新的语言环境非常容易。有很多可用的帮助。

Windows:我一直在调查,但没有定论。尽管有一些帖子可以提供答案,但是我并没有感到追求它的冲动。

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.


回答 16

如果我理解正确,那么错误的主要来源就是语言环境名称的确切语法。尤其是在发行版之间似乎有所不同。我已经在这里以不同的答案/评论提到过:

de_DE.utf8
de_DE.UTF-8

即使这对于人类而言显然是相同的,但对于您的标准确定性算法而言,却并不适用。

因此,您可能会执行以下操作:

DESIRED_LOCALE=de
DESIRED_LOCALE_COUNTRY=DE
DESIRED_CODEPAGE_RE=\.[Uu][Tt][Ff].?8
if [ $(locale -a | grep -cE "${DESIRED_LOCALE}_${DESIRED_LOCALE_COUNTRY}${DESIRED_CODEPAGE_RE}") -eq 1 ]
then
    export LC_ALL=$(locale -a | grep -m1 -E "${DESIRED_LOCALE}_${DESIRED_LOCALE_COUNTRY}${DESIRED_CODEPAGE_RE}")
    export LANG=$LC_ALL
else
    echo "Not exactly one desired locale definition found: $(locale -a | grep -E "${DESIRED_LOCALE}_${DESIRED_LOCALE_COUNTRY}${DESIRED_CODEPAGE_RE}")" >&2
fi

if I understand correctly, the main source of error here is the exact syntax of the locale-name. Especially as it seems to differ between distributions. I’ve seen mentioned here in different answers/comments:

de_DE.utf8
de_DE.UTF-8

Even though this is obviously the same for a human being, the same does not hold for your standard deterministic algorithm.

So you will probably do something along the lines of:

DESIRED_LOCALE=de
DESIRED_LOCALE_COUNTRY=DE
DESIRED_CODEPAGE_RE=\.[Uu][Tt][Ff].?8
if [ $(locale -a | grep -cE "${DESIRED_LOCALE}_${DESIRED_LOCALE_COUNTRY}${DESIRED_CODEPAGE_RE}") -eq 1 ]
then
    export LC_ALL=$(locale -a | grep -m1 -E "${DESIRED_LOCALE}_${DESIRED_LOCALE_COUNTRY}${DESIRED_CODEPAGE_RE}")
    export LANG=$LC_ALL
else
    echo "Not exactly one desired locale definition found: $(locale -a | grep -E "${DESIRED_LOCALE}_${DESIRED_LOCALE_COUNTRY}${DESIRED_CODEPAGE_RE}")" >&2
fi

回答 17

python寻找.UFT-8,但您可能已经让.utf8尝试使用sudo dpkg-reconfigure语言环境安装.UFT-8软件包

python looks for .UFT-8, but you probably have .utf8 try installing the .UFT-8 packages with sudo dpkg-reconfigure locales


回答 18

首先,通过执行以下操作确保安装了语言包:

sudo apt-get install language-pack-en-base


sudo dpkg-reconfigure locales

first, make sure you have the language pack installed by doing :

sudo apt-get install language-pack-en-base


sudo dpkg-reconfigure locales

声明:本站所有文章,如无特殊说明或标注,均为本站原创发布。任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。