rocker-org / ml

experimental machine learning container
GNU General Public License v2.0
50 stars 13 forks source link

Upgrading pip in Dockerfile causes "cannot import name main" error #7

Closed MarkEdmondson1234 closed 5 years ago

MarkEdmondson1234 commented 5 years ago

Using this Dockerfile from the gpu folder:

RUN apt-get update \
    && apt-get upgrade -y -q \
    && apt-get install -y --no-install-recommends \
           r-base \
           r-base-dev \
           r-cran-littler \
           libxml2-dev \
           libxt-dev \
           libssl-dev \
           libcurl4-openssl-dev \
           imagemagick \
           python-pip \
           libpython2.7 \
    && pip install --upgrade pip==9.0.3 \
    && pip install virtualenv \
    && echo 'options(repos = c(CRAN = "https://cloud.r-project.org"))' >> /etc/R/Rprofile.site \
    && /usr/lib/R/site-library/littler/examples/install.r tensorflow keras \
    && r -e "keras::install_keras(tensorflow = '1.4.1-gpu')"

Which resulted in this error:

...snip...
Collecting pip
  Downloading https://files.pythonhosted.org/packages/d7/41/34dd96bd33958e52cb4da2f1bf0818e396514fd4f4725a79199564cd0c20/pip-19.0.2-py2.py3-none-any.whl (1.4MB)
Installing collected packages: pip
  Found existing installation: pip 8.1.1
    Not uninstalling pip at /usr/lib/python2.7/dist-packages, outside environment /usr
Successfully installed pip-19.0.2
Traceback (most recent call last):
  File "/usr/bin/pip", line 9, in <module>
    from pip import main
ImportError: cannot import name main
The command '/bin/sh -c apt-get update     && apt-get upgrade -y -q     && apt-get install -y --no-install-recommends            r-base            r-base-dev            r-cran-littler            libxml2-dev            libxt-dev            libssl-dev            libcurl4-openssl-dev            imagemagick            python-pip            libpython2.7     && pip install --upgrade pip     && pip install virtualenv     && echo 'options(repos = c(CRAN = "https://cloud.r-project.org"))' >> /etc/R/Rprofile.site     && /usr/lib/R/site-library/littler/examples/install.r tensorflow keras && r -e "keras::install_keras(tensorflow = '1.4.1-gpu')"' returned a non-zero code: 1
ERROR
ERROR: build step 0 "gcr.io/cloud-builders/docker" failed: exit status 1

The solution as suggested here https://github.com/pypa/pip/issues/5240 is to change the install line.

    && python -m pip install --upgrade pip \
cboettig commented 5 years ago

Can you try this Dockerfile instead?

MarkEdmondson1234 commented 5 years ago

That link is dead, do you mean this one?

cboettig commented 5 years ago

@MarkEdmondson1234 yup, that one!