1. 程式人生 > >Debian下Cannot set LC_CTYPE to default locale: No such file or directory解決方法

Debian下Cannot set LC_CTYPE to default locale: No such file or directory解決方法

把語言環境變數改為英文

將Ubuntu系統語言環境改為英文的en_US.UTF-8

檢視當前系統語言環境

locale

編輯配置檔案。將zh_US.UTF-8改為en_US.UTF-8。zh改為en

sudo nano /etc/default/locale
LANG="en_US.UTF-8"
LANGUAGE="en_US:en"

繼續檢視更改後的系統語言變數,假設出現下列錯誤,說明沒安裝en_US的local

[email protected]:~$ locale
locale: Cannot set LC_CTYPE to default locale: No such file or directory
locale: Cannot set LC_MESSAGES to default locale: No such file or directory
locale: Cannot set LC_ALL to default locale: No such file or directory
LANG=en_US.UTF-8
LANGUAGE=en_US:en
LC_CTYPE="en_US.UTF-8"
LC_NUMERIC="en_US.UTF-8"
LC_TIME="en_US.UTF-8"
LC_COLLATE="en_US.UTF-8"
LC_MONETARY="en_US.UTF-8"
LC_MESSAGES="en_US.UTF-8"
LC_PAPER="en_US.UTF-8"
LC_NAME="en_US.UTF-8"
LC_ADDRESS="en_US.UTF-8"
LC_TELEPHONE="en_US.UTF-8"
LC_MEASUREMENT="en_US.UTF-8"
LC_IDENTIFICATION="en_US.UTF-8"
LC_ALL=

檢視系統內安裝的locale

[email protected]:~$ locale -a
locale: Cannot set LC_CTYPE to default locale: No such file or directory
locale: Cannot set LC_MESSAGES to default locale: No such file or directory
locale: Cannot set LC_COLLATE to default locale: No such file or directory
C
POSIX
zh_CN.utf8
zh_SG.utf8

看吧,沒裝en_US.UTF-8

安裝en_US.UTF-8

sudo locale-gen en_US.UTF-8

再次檢視,應該一切正常了。

[email protected]:/usr/share/locales$ locale
LANG=en_US.UTF-8
LANGUAGE=en_US:en
LC_CTYPE="en_US.UTF-8"
LC_NUMERIC="en_US.UTF-8"
LC_TIME="en_US.UTF-8"
LC_COLLATE="en_US.UTF-8"
LC_MONETARY="en_US.UTF-8"
LC_MESSAGES="en_US.UTF-8"
LC_PAPER="en_US.UTF-8"
LC_NAME="en_US.UTF-8"
LC_ADDRESS="en_US.UTF-8"
LC_TELEPHONE="en_US.UTF-8"
LC_MEASUREMENT="en_US.UTF-8"
LC_IDENTIFICATION="en_US.UTF-8"
LC_ALL=