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

我该怎么解决呢?


当前回答

尝试重新安装:

localess apt-get install --reinstall locales

更多信息请参见如何更改默认区域设置

其他回答

仅适用于macOS和Mac OS X用户

我在使用Git时也得到了同样的警告

要解决此警告,取消选中“在启动时设置语言环境变量”选项并重新启动终端。下面的屏幕截图代表了我的终端设置。

如果不关心语言环境问题,可以设置PERL_BADLANG=0。当然,这可能导致不正确的本地化。

您需要在/etc/default/locale中适当地配置语言环境、注销、登录,然后运行常规命令

root@host:~# echo -e 'LANG=en_US.UTF-8\nLC_ALL=en_US.UTF-8' > /etc/default/locale
root@host:~# exit
local-user@local:~$ ssh root@host
root@host:~# locale-gen en_US.UTF-8
root@host:~# dpkg-reconfigure locales
sudo nano /etc/locale.gen

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

然后运行:

sudo /usr/sbin/locale-gen

来源:配置区域设置

将LC_TYPE环境变量设置为默认的区域语言“C”将有助于消除此警告。

执行export LC_CTYPE="C",然后尝试执行perl命令。

附注:您需要在/etc/environment文件或/etc/default/locale文件中设置此变量以获得永久解决方案。