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

我该怎么解决呢?


当前回答

我在Mac M1 Monterey上试过这些方法,但都不行。 禁用该消息的快速方法是: 打开终端->首选项->高级选项卡->取消勾选以在启动时设置区域环境变量

其他回答

对我来说,在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

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

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

perl: warning: Falling back to the standard locale ("C").
locale: Cannot set LC_ALL to default locale: No such file or directory

解决方案:

试试这个(uk_UA。UTF-8是我当前的语言环境。编写语言环境,例如en_US。utf - 8 !)

sudo locale-gen uk_UA.UTF-8

这。

sudo dpkg-reconfigure locales