当我运行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").

我该怎么解决呢?


当前回答

对我来说,在Ubuntu 16.04 (Xenial Xerus)上,以下工作:

root@host:~#locale-gen en_GB.UTF-8
root@host:~#localectl set-locale LANG=en_GB.UTF-8,LC_ALL=en_GB.UTF-8

然后重新启动…

其他回答

以下是如何在Mac OS X v10.7 (Lion)或Cygwin (Windows 10)上解决这个问题:

在主机上的bashrc或bash_profile文件中添加以下代码行:

# Setting for the new UTF-8 terminal support in Lion
export LC_CTYPE=en_US.UTF-8
export LC_ALL=en_US.UTF-8

如果你使用Z shell (zsh),编辑文件zshrc:

# Setting for the new UTF-8 terminal support in Lion
LC_CTYPE=en_US.UTF-8
LC_ALL=en_US.UTF-8

如果有人有一台带有Strato的服务器并试图找出这个问题,请检查/etc/profile.我在重新生成区域设置和设置变量太长时间之前,我发现在这个文件的末尾有两行覆盖了我的区域设置。

前面的答案都是错的。消息是明确的-缺少区域设置。解决方案是添加适当的区域设置。您可以通过编辑/etc/locale.生成文件,删除被报告为缺失的地区前面的#符号,然后发出命令:

$ sudo locale-gen

这将实际生成在/etc/locale.中指定的地区Gen,因此消息将不会显示。

将以下内容添加到/etc/environment中,为我解决了Debian和Ubuntu上的问题(当然,修改以匹配您想使用的语言环境):

LANGUAGE=en_US.UTF-8
LC_ALL=en_US.UTF-8
LANG=en_US.UTF-8
LC_CTYPE=en_US.UTF-8
sudo nano /etc/locale.gen

取消注释你想要使用的地区(例如en_US。utf - 8 utf - 8):

然后运行:

sudo /usr/sbin/locale-gen

来源:配置区域设置