VikParuchuri / apartment-finder

A Slack bot that helps you find an apartment.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Import error when building the docker image

Wartz opened this issue · comments

mac OS sierra
Python 3.5.2
Docker 1.13.1

One of the dependencies for slackclient in requirements.txt is setuptools. The docker build skips over installing it and then fails with the following error.

Found existing installation: setuptools 3.3
    Not uninstalling setuptools at /usr/lib/python3/dist-packages, owned by OS
  Running setup.py install for simplegeneric
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/usr/local/lib/python3.4/dist-packages/setuptools/__init__.py", line 12, in <module>
        import setuptools.version
      File "/usr/local/lib/python3.4/dist-packages/setuptools/version.py", line 1, in <module>
        import pkg_resources
      File "/usr/local/lib/python3.4/dist-packages/pkg_resources/__init__.py", line 70, in <module>
        import packaging.version
    ImportError: No module named 'packaging'
    Complete output from command /usr/bin/python3 -c "import setuptools, tokenize;__file__='/tmp/pip_build_root/simplegeneric/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-su8foqsj-record/install-record.txt --single-version-externally-managed --compile:
    Traceback (most recent call last):

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

  File "/usr/local/lib/python3.4/dist-packages/setuptools/__init__.py", line 12, in <module>

    import setuptools.version

  File "/usr/local/lib/python3.4/dist-packages/setuptools/version.py", line 1, in <module>

    import pkg_resources

  File "/usr/local/lib/python3.4/dist-packages/pkg_resources/__init__.py", line 70, in <module>

    import packaging.version

ImportError: No module named 'packaging'

I got around the error by adding

RUN pip3 install setuptools==33.1.1

to requirements.txt above the line

RUN pip3 install -r /tmp/requirements.txt

The build works with setup tools 33.x, but not 34.x. I'm not sure if this is a bug on the part of this app or setup tools. vOv.

I think this is caused by an old version of pip re pypa/setuptools#937

I made this change to Dockerfile:

diff --git a/Dockerfile b/Dockerfile
index 01f32e5..ee00f65 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -27,7 +27,9 @@ RUN apt-get update && \
 
 RUN mkdir -p /tmp
 COPY requirements.txt /tmp/requirements.txt
+RUN pip3 install -U pip
 RUN pip install -r /tmp/requirements.txt
 
 COPY deployment/supervisord.conf /etc/supervisor/conf.d/supervisord.conf
 RUN mkdir -p /opt/wwc