2016-03-29 43 views
0

我是新來的碼頭,並希望如果有人可以幫助我擺脫這個錯誤,同時建立碼頭圖像。這是給某種地區的錯誤。我怎樣才能擺脫這個錯誤?Locale.Error與建設基於Python的碼頭

Collecting pip 
Downloading pip-8.1.1-py2.py3-none-any.whl (1.2MB) 
Collecting setuptools 
Downloading setuptools-20.3.1-py2.py3-none-any.whl (508kB) 
Collecting wheel 
Downloading wheel-0.29.0-py2.py3-none-any.whl (66kB) 
Installing collected packages: pip, setuptools, wheel 
Successfully installed pip-8.1.1 setuptools-20.3.1 wheel-0.29.0 
+ pip install --no-cache-dir --upgrade pip==8.0.2 
Traceback (most recent call last): 
File "/usr/bin/pip", line 11, in 
sys.exit(main()) 
File "/usr/lib/python2.7/site-packages/pip/__init__.py", line 215, in main 
locale.setlocale(locale.LC_ALL, '') 
File "/usr/lib64/python2.7/locale.py", line 547, in setlocale 
return _setlocale(category, locale) 
locale.Error: unsupported locale setting 
The command '/bin/sh -c set -ex && gpg --keyserver ha.pool.sks-keyservers.net --recv-keys "$GPG_KEY" && curl -fSL 'https://bootstrap.pypa.io/get-pip.py' | python2 && pip install --no-cache-dir --upgrade pip==$PYTHON_PIP_VERSION' returned a non-zero code: 1 

這是我Dockerfile:

FROM mybase:1.0.7 

RUN set -x \ 
&& yum install -y python-devel libffi-devel python-cffi \ 
&& yum clean all 

ENV LANG C.UTF-8 

ENV GPG_KEY C01E1CAD5EA2C4F0B8E3571504C367C218ADD4FF 

ENV PYTHON_VERSION 2.7.11 

ENV PYTHON_PIP_VERSION 8.0.2 

RUN set -ex \ 
&& gpg --keyserver ha.pool.sks-keyservers.net --recv-keys "$GPG_KEY" \ 
&& curl -fSL 'https://bootstrap.pypa.io/get-pip.py' | python2 \ 
&& pip install --no-cache-dir --upgrade pip==$PYTHON_PIP_VERSION 

RUN pip install --no-cache-dir virtualenv 

CMD ["python2"] 

回答

1

locale.setlocale文檔說的locale應該是有效的。如果傳遞一個空字符串,則使用LANG變量來設置區域設置。此錯誤可能是因爲您的LANG不是受支持的語言環境

在您的泊塢窗腳本中,您將LANG設置爲C.UTF-8。它看起來像C.UTF-8不是glibc中支持的語言環境,因此我在Python中猜測(請參閱thisthis)。

您可以將您的LANG設置爲受支持的類型,如en_US.UTF-8(我的計算機上的默認值)。

在Python的2.6,我得到下面的結果

Python 2.6.6 (r266:84292, Jan 22 2014, 09:42:36) 
[GCC 4.4.7 20120313 (Red Hat 4.4.7-4)] on linux2 
Type "help", "copyright", "credits" or "license" for more information. 
>>> import locale 
>>> locale.setlocale(locale.LC_ALL, "") 
'en_US.utf8' 
>>> locale.setlocale(locale.LC_ALL, "C.UTF-8") 
Traceback (most recent call last): 
    File "<stdin>", line 1, in <module> 
    File "/usr/lib64/python2.6/locale.py", line 513, in setlocale 
    return _setlocale(category, locale) 
locale.Error: unsupported locale setting 
>>> locale.setlocale(locale.LC_ALL, "en_US.UTF-8") 
'en_US.UTF-8' 
>>> locale.setlocale(locale.LC_ALL, "de_DE.UTF-8") 
'de_DE.UTF-8' 

您可以通過運行

$ locale -a 
查看計算機上可用的語言環境