MediaMath/t1-python

Not able to pip3 install terminalOne package inside docker container (base out of Debian)

Closed this issue · 7 comments

When user try to pip3 install terminalOne package inside docker container, unicodeDecodeError is seen
complete error trace :

Running setup.py (path:/tmp/pip-build-1a2v5dg9/terminalOne/setup.py) egg_info for package terminalOne
    Traceback (most recent call last):
      File "<string>", line 17, in <module>
      File "/tmp/pip-build-1a2v5dg9/terminalOne/setup.py", line 36, in <module>
        long_description=fread('README.rst'),
      File "/tmp/pip-build-1a2v5dg9/terminalOne/setup.py", line 14, in fread
        return 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 0xe2 in position 9866: ordinal not in range(128)
    Complete output from command python setup.py egg_info:
    Traceback (most recent call last):

  File "<string>", line 17, in <module>

  File "/tmp/pip-build-1a2v5dg9/terminalOne/setup.py", line 36, in <module>

    long_description=fread('README.rst'),

  File "/tmp/pip-build-1a2v5dg9/terminalOne/setup.py", line 14, in fread

    return 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 0xe2 in position 9866: ordinal not in range(128)

Content of the docker file I am trying to build

# Starting from base image
FROM debian
#ENV LANG en_US.UTF-8

# Install Python & pip
RUN apt-get upgrade -y
RUN apt-get update -y

RUN apt-get install -y --fix-missing python3.4 python3-pip python3.4-dev python-pip

# Insall xvfb
RUN apt-get install -y xvfb

# Install requirements via pip  
VOLUME /UI-Automation
WORKDIR /UI-Automation
RUN pip3 install -I apipkg astroid coverage EasyProcess execnet logilab-common pylint pytest pytest-html pytest-xdist python-termstyle selenium six wheel backports.functools-lru-cache configparser enum34 glob2 isort lazy-object-proxy Mako MarkupSafe mccabe parse parse-type py pytest-bdd pytest-rerunfailures wrapt terminalOne git+https://github.com/okken/pytest-expect.git@master#egg=pytest-expect 

# Set an entrypoint
ENTRYPOINT ["py.test"]

The Dockerfile you pasted has it commented out. With it uncommented does it still do that?

Additionally, can you humor me and also try setting ENV LC_ALL en_US.UTF-8 as described in this AskUbuntu answer?

It looks like LC_ALL overrides LANG on Debian:

pswaminathan on debian in ~
$ env
...
LC_ALL=en_US.UTF-8
LANG=en_US.UTF-8

pswaminathan on debian in ~
$ python
Python 2.7.4 (default, Apr 29 2013, 15:18:33)
[GCC 4.4.5] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import locale
>>> locale.getpreferredencoding()
'UTF-8'
>>>

pswaminathan on debian in ~
$ LANG=POSIX python
Python 2.7.4 (default, Apr 29 2013, 15:18:33)
[GCC 4.4.5] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import locale
>>> locale.getpreferredencoding()
'UTF-8'
>>>

pswaminathan on debian in ~
$ LC_ALL=POSIX python
Python 2.7.4 (default, Apr 29 2013, 15:18:33)
[GCC 4.4.5] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import locale
>>> locale.getpreferredencoding()
'ANSI_X3.4-1968'
>>>

So I think LC_ALL is set to something else by the base container, and LANG isn't enough to override it.

Yeah, for your previous question.
I tried uncommenting LANG, and it does not work for me.

Let me try ENV LC_ALL en_US.UTF-8

Same error even after setting ENV LC_ALL en_US.UTF-8

Ok it finally worked using following docker image as base image : https://hub.docker.com/r/pfcarrier/debian-locale/builds/biksnydxmevjscmbkbclu6c/

Not sure if you want to close this issue now.

I have the same issue. The solution is manually setting the LOCALE to UTF8 in the image as rronakk mentioned.
By the way, I noticed this warning message debconf: delaying package configuration, since apt-utils is not installed in the log. Is it something we need to worry about?

While I am certainly sympathetic to this issue, the issue here is that the Docker image doesn't come out-of-the-box configured to use UTF-8. In my mind, this is an issue of the Docker image in question, not t1-python. I left the issue open originally because I wasn't sure if I wanted to include some instructions in the docs for how to configure it to work correctly. But upon further reflection, it would be documenting an edge case that isn't really relevant otherwise.

Definitely thanks to you both for bringing this up, and I think we'll let this issue serve as a reference for potential future questions on it.

@zachliu : Regarding the message, take a look at this SF answer. This is more of an issue with the Debian image you're using not having apt-utils installed. This is only worrisome if packages you're using require some form of configuration through aptitude before use. If the only packages you're installing through apt-get are Python, pip, etc, I can't see how this would cause real problems. You could try first including a RUN apt-get install -y apt-utils before any other apt-get lines and see if anything changes.