[英]Mysterious UnicodeDecodeError in python3 while building Docker container
I am creating a python 3 application. 我正在创建一个python 3应用程序。 https://github.com/Omrigan/TED-analysis
https://github.com/Omrigan/TED-analysis
To deploy I want to use Docker with Dockerfile located in root of my Github repo (you may check it). 要部署我想使用Docker和位于我的Github仓库的根目录中的Dockerfile(您可以检查它)。 So, when I do "docker build ."
所以,当我做“docker build”时。 I get an error on this line:
我在这一行收到错误:
RUN pip3 install --upgrade -r /root/ted_talks/requirements.txt
Log from console: 从控制台登录:
Collecting httpretty==0.8.10 (from smart-open>=1.2.1->gensim->-r /root/ted_talks/requirements.txt (line 4))
Downloading httpretty-0.8.10.tar.gz (41kB)
Complete output from command python setup.py egg_info:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/tmp/pip-build-em459e9u/httpretty/setup.py", line 86, in <module>
version=read_version(),
File "/tmp/pip-build-em459e9u/httpretty/setup.py", line 46, in read_version
finder.visit(ast.parse(local_file('httpretty', '__init__.py')))
File "/tmp/pip-build-em459e9u/httpretty/setup.py", line 78, in <lambda>
open(os.path.join(os.path.dirname(__file__), *f)).read()
File "/usr/lib/python3.4/encodings/ascii.py", line 26, in decode
return codecs.ascii_decode(input, self.errors)[0]
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 133: ordinal not in range(128)
So, what should I do? 所以我该怎么做?
It seems that httpretty does some funky stuff to locate its version number - It opens one of the source files, which contains non-ascii chars, without declaring an encoding. 似乎httpretty做了一些时髦的东西来找到它的版本号 - 它打开一个源文件,其中包含非ascii字符,而不声明编码。 In Python 3, this will use your locale, which in your case, seems to be corrupt or set to
LANG=C|POSIX
. 在Python 3中,这将使用您的语言环境,在您的情况下,它似乎已损坏或设置为
LANG=C|POSIX
。
You have the following options: 您有以下选择:
httpretty/__init__.py
and remove the non-ascii chars ( ã
). httpretty/__init__.py
并删除非ascii字符( ã
)。 en_US.UTF-8
en_US.UTF-8
I see that httpretty 0.8.14 has references to being Python 3 compliant. 我看到httpretty 0.8.14引用了兼容Python 3的内容。 Try installing with:
尝试安装:
pip3 install httpretty==0.8.14
I had the same problem. 我有同样的问题。 The cause was the locale of my choice (ie en_US.utf8) was not installed.
原因是我选择的语言环境(即en_US.utf8)未安装。 Installing this locale solved my problem.
安装此语言环境解决了我的问题。
To set the locale: 要设置区域设置:
locale-gen en_US.utf8
dpkg-reconfigure locales
and choose en_US.utf8 as your default locale 并选择en_US.utf8作为默认语言环境
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.