Skip to content
This repository has been archived by the owner on Jun 25, 2022. It is now read-only.

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

Closed
MarkEdmondson1234 opened this issue Feb 10, 2019 · 3 comments

Comments

@MarkEdmondson1234
Copy link
Contributor

MarkEdmondson1234 commented Feb 10, 2019

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 pypa/pip#5240 is to change the install line.

    && python -m pip install --upgrade pip \
@cboettig
Copy link
Member

Can you try this Dockerfile instead?

@MarkEdmondson1234
Copy link
Contributor Author

MarkEdmondson1234 commented Feb 12, 2019

That link is dead, do you mean this one?

@cboettig
Copy link
Member

@MarkEdmondson1234 yup, that one!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants