unsupported-locale-setting

前端之家收集整理的这篇文章主要介绍了unsupported-locale-setting前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

1 问题

今天在测试服务器上执行 pip list 发现

(conf) root@xxxxx:xxxxx# pip list
Traceback (most recent call last):
  File "/srv/www/vinyl.ddapp.com/conf/bin/pip",line 11,in <module>
    sys.exit(main())
  File "/srv/www/vinyl.ddapp.com/conf/lib/python3.6/site-packages/pip/__init__.py",line 215,in main
    locale.setlocale(locale.LC_ALL,'')
  File "/usr/lib/python3.6/locale.py",line 598,in setlocale
    return _setlocale(category,locale)
locale.Error: unsupported locale setting

这就很尴尬了,看下本机的 locale

locale: Cannot set LC_CTYPE 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=
LC_CTYPE=zh_CN.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=

发现 LC_ALL 为空

2 解决方法

2.1 重置环境变量

export LC_ALL="en_US.UTF-8"

2.2 重新刷入配置

运行命令 dpkg-reconfigure locales

Generating locales (this might take a while)...
  en_AG.UTF-8... done
  en_AU.UTF-8... done
  en_BW.UTF-8... done
  en_CA.UTF-8... done
  en_DK.UTF-8... done
  en_GB.UTF-8... done
  en_HK.UTF-8... done
  en_IE.UTF-8... done
  en_IN.UTF-8... done
  en_NG.UTF-8... done
  en_NZ.UTF-8... done
  en_PH.UTF-8... done
  en_SG.UTF-8... done
  en_US.UTF-8... done
  en_ZA.UTF-8... done
  en_ZM.UTF-8... done
  en_ZW.UTF-8... done
Generation complete.

在次查看 locale

LANG=en_US.UTF-8
LANGUAGE=
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=en_US.UTF-8

最后运行 pip list 就正常了

原文链接:https://www.f2er.com/ubuntu/350607.html

猜你在找的Ubuntu相关文章