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

我该怎么解决呢?


当前回答

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

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

# then regenerate
sudo locale-gen

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

其他回答

将缺失的地区添加到.bash_profile文件中:

echo "export LANGUAGE=en_US.UTF-8
export LANG=en_US.UTF-8
export LC_ALL=en_US.UTF-8">>~/.bash_profile

然后来源你的.bash_profile文件:

source ~/.bash_profile

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

第一:

sudo apt-get purge locales

然后:

sudo aptitude install locales

还有著名的:

sudo dpkg-reconfigure locales

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

在我的例子中,这是输出:

LANGUAGE = (unset),
LC_ALL = (unset),
LC_PAPER = "ro_RO.UTF-8",
LC_ADDRESS = "ro_RO.UTF-8",
....

解决方案是:

sudo locale-gen ro_RO.UTF-8

对我来说,在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.5 (Lion)上,要修复一些Django错误,请在我的~/。bash_profile我已经设置:

export LANG=en_EN.UTF-8
export LC_COLLATE=$LANG
export LC_CTYPE=$LANG
export LC_MESSAGES=$LANG
export LC_MONETARY=$LANG
export LC_NUMERIC=$LANG
export LC_TIME=$LANG
export LC_ALL=$LANG

在很长一段时间里,我在使用Perl时都得到了这样的警告。

我的坏!我后来才意识到,我的系统是en_US.UTF-8! 我只是通过改变

export LANG=en_EN.UTF-8

to

export LANG=en_US.UTF-8