当我运行perl时,我得到警告:

perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
    LANGUAGE = (unset),
    LC_ALL = (unset),
    LANG = "en_US.UTF-8"
are supported and installed on your system.
perl: warning: Falling back to the standard locale ("C").

我该怎么解决呢?


当前回答

我现在使用这个:

$ cat /etc/environment
...
LC_ALL=en_US.UTF-8
LANG=en_US.UTF-8

然后注销SSH会话,重新登录。

旧的回答:

只有这一点对我有帮助:

$ 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=ru_RU.UTF-8
LC_TIME=ru_RU.UTF-8
LC_COLLATE="en_US.UTF-8"
LC_MONETARY=ru_RU.UTF-8
LC_MESSAGES="en_US.UTF-8"
LC_PAPER=ru_RU.UTF-8
LC_NAME=ru_RU.UTF-8
LC_ADDRESS=ru_RU.UTF-8
LC_TELEPHONE=ru_RU.UTF-8
LC_MEASUREMENT=ru_RU.UTF-8
LC_IDENTIFICATION=ru_RU.UTF-8
LC_ALL=

$ sudo su

# export LANGUAGE=en_US.UTF-8
# export LANG=en_US.UTF-8
# export LC_ALL=en_US.UTF-8

# locale-gen en_US.UTF-8
Generating locales...
  en_US.UTF-8... up-to-date
Generation complete.

# dpkg-reconfigure locales
Generating locales...
  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_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... up-to-date
  en_ZA.UTF-8... done
  en_ZM.UTF-8... done
  en_ZW.UTF-8... done
Generation complete.

# exit

$ locale
LANG=en_US.UTF-8
LANGUAGE=en_US.UTF-8
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

其他回答

在Debian上,经过大量搜索,这个方法奏效了。

第一:

sudo apt-get purge locales

然后:

sudo aptitude install locales

还有著名的:

sudo dpkg-reconfigure locales

这消除了系统的区域设置,然后重新安装区域设置,并将libc6从2.19降级到2.13,这就是问题所在。然后它再次配置区域设置。

这通常意味着您还没有正确地在Linux机器上设置区域设置。

在Debian或Ubuntu上,这意味着你需要去做

$ sudo locale-gen
$ sudo dpkg-reconfigure locales

另参见man locale-gen。

Use:

export LANGUAGE=en_US.UTF-8
export LC_ALL=en_US.UTF-8
export LANG=en_US.UTF-8
export LC_CTYPE=en_US.UTF-8

它适用于Debian。我不知道为什么,但是locale-gen没有结果。

重要!这是暂时的解决办法。它必须在每个会话中运行。

添加LC_ALL = " en_GB。Utf8”到/etc/environment并重新启动。这是所有。

我有多个用户使用不同的外壳,所以在我的情况下,这解决了:

检查哪个外壳 echo $ 0 如果bash #设置locale\nLC_CTYPE=en_US. utf -8\nLC_ALL=en_US. utf -8UTF-8" >> .bashrc 如果zsh #设置locale\nLC_CTYPE=en_US. utf -8\nLC_ALL=en_US. utf -8UTF-8" >> .zshrc