我想在我的 ubuntu 机器上使用 Ansible。我尝试使用 ping 模块,但它抱怨找不到xmltodict
python 库。因此我想使用 pip 安装缺少的模块。当我尝试:
pip install xmltodict
我得到:
Traceback (most recent call last):
File "/usr/bin/pip", line 11, in <module>
sys.exit(main())
File "/usr/lib/python2.7/dist-packages/pip/__init__.py", line 215, in main
locale.setlocale(locale.LC_ALL, '')
File "/usr/lib/python2.7/locale.py", line 583, in setlocale
return _setlocale(category, locale)
locale.Error: unsupported locale setting
我正在运行 Ubuntu16.04 LTS。我该如何解决这个问题?谢谢
答案1
解决方案如下:https://stackoverflow.com/questions/36394101/pip-install-locale-error-unsupported-locale-setting
由于我运行的是python2.7:
$uname -a
Linux tools1-itigo-tech 4.4.0-24-generic #43-Ubuntu SMP Wed Jun 8 19:27:37 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux
$python --version
Python 2.7.11+
$unset LC_ALL
$pip install xmltodict
Traceback (most recent call last):
File "/usr/bin/pip", line 11, in <module>
sys.exit(main())
File "/usr/lib/python2.7/dist-packages/pip/__init__.py", line 215, in main
locale.setlocale(locale.LC_ALL, '')
File "/usr/lib/python2.7/locale.py", line 583, in setlocale
return _setlocale(category, locale)
locale.Error: unsupported locale setting
$export LC_ALL=C
$pip install xmltodict
Collecting xmltodict
Downloading xmltodict-0.10.2.tar.gz
Building wheels for collected packages: xmltodict
Running setup.py bdist_wheel for xmltodict ... done
Stored in directory: /home/usr/.cache/pip/wheels/2a/dc/70/da8958d7089d994c8614bc38210f64855f09615e85707bf615
Successfully built xmltodict
Installing collected packages: xmltodict
Successfully installed xmltodict
答案2
导出 LC_ALL=C
这会起作用