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

我该怎么解决呢?


当前回答

导出变量

$ 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

下一个运行

$ sudo locale-gen
$ sudo dpkg-reconfigure locales 

当您运行dpkg-reconfigure locale时,它会要求您选择locale,选择en_US。utf - 8。如果通过选择所有区域设置来运行此操作,则需要一些时间来配置。

其他回答

如果您正在使用反引导创建rootfs,则需要生成区域设置。你可以通过运行:

# (optional) enable missing locales
sudo nano /etc/locale.gen

# then regenerate
sudo locale-gen

这个技巧来自https://help.ubuntu.com/community/Xen

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没有结果。

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

以下是如何在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

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

第一:

sudo apt-get purge locales

然后:

sudo aptitude install locales

还有著名的:

sudo dpkg-reconfigure locales

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

对于Ubuntu来说,

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

这对我很管用。