Why does pip consistently fail to install pytest-django? .dist-info directory not found error

Viewed 1716

I have a docker container setup that keeps failing to install this pytest-django==3.4.8 from requirements.txt. If I comment it out everything else installs correctly. Tried everything from tearing down the setup and rebuilding to upgrading pip to deleting the pip cache and still nothing. Any help is appreciated!

Exception:
Traceback (most recent call last):
  File "/usr/lib/python2.7/dist-packages/pip/basecommand.py", line 209, in main
    status = self.run(options, args)
  File "/usr/lib/python2.7/dist-packages/pip/commands/install.py", line 335, in run
    prefix=options.prefix_path,
  File "/usr/lib/python2.7/dist-packages/pip/req/req_set.py", line 732, in install
    **kwargs
  File "/usr/lib/python2.7/dist-packages/pip/req/req_install.py", line 837, in install
    self.move_wheel_files(self.source_dir, root=root, prefix=prefix)
  File "/usr/lib/python2.7/dist-packages/pip/req/req_install.py", line 1039, in move_wheel_files
    isolated=self.isolated,
  File "/usr/lib/python2.7/dist-packages/pip/wheel.py", line 346, in move_wheel_files
    assert info_dir, "%s .dist-info directory not found" % req
AssertionError: pytest>=3.6 .dist-info directory not found

The DockerFile in question:

FROM ubuntu:16.04

RUN echo ttf-mscorefonts-installer msttcorefonts/accepted-mscorefonts-eula select true | debconf-set-selections

# Set the locale
RUN apt-get clean && apt-get update && apt-get install -y locales
RUN locale-gen en_US.UTF-8
ENV LANG en_US.UTF-8
ENV LANGUAGE en_US:en
ENV LC_ALL en_US.UTF-8

# Install our package dependencies
RUN apt-get update && apt-get install -y \
  git \
  autoconf \
  automake \
  bison \
  build-essential \
  curl \
  git-core \
  libc6-dev \
  libcurl4-openssl-dev \
  libffi-dev \
  libgdbm-dev \
  libreadline6-dev \
  libsqlite3-dev \
  libssl-dev \
  libtool \
  libxml2-dev \
  libxslt-dev \
  libyaml-dev \
  libxmlsec1-dev \
  ncurses-dev \
  ntpdate \
  openssl \
  pkg-config \
  python-pip \
  python-dev \
  sqlite3 \
  unzip \
  libsasl2-dev \
  zlib1g \
  zlib1g-dev \
  vim \
  apt-transport-https \
  awscli \
  libwww-perl \
  libdatetime-perl \
  unzip \
  g++ \
  dnsmasq \
  python3-pip \
  jq \
  htop \
  cron \
  libfreetype6 \
  libfreetype6-dev \
  libfontconfig \
  libx11-dev \
  libxrender-dev \
  zlib1g-dev \
  fontconfig \
  libmagickwand-dev \
  wget \
  openjdk-8-jre-headless \
  mupdf \
  mupdf-tools \
  pdftk \
  imagemagick \
  tesseract-ocr \
  tesseract-ocr-eng \
  libtesseract-dev \
  libleptonica-dev \
  msttcorefonts

# Create our /srv directory
WORKDIR /srv

# Copy dependencies
COPY . /srv

# Copy WKHTMLTOPDF
COPY ./wkhtmltox /opt/wkhtmltox

# Copy our AWS Credentials file
COPY ./.aws /root/.aws

# Install our python dependencies
RUN pip install -r /srv/git/django/requirements.txt
RUN pip install django_extensions

Temporary Workaround I removed pytest-django==3.4.8 from requirements.txt which allows the package install process to complete. Then I entered the box and checked pip show pytest which produces no result. So I manually install pytest==4.6 and pytest-django==3.4.8 and it works. Unfortunately this doesn't get to the heart of why it fails in the first place..

1 Answers

The fix comes down to updating pip and the symbolic link in the DockerFile:

RUN pip install -U pip
RUN rm /usr/bin/pip
RUN ln -s /usr/local/bin/pip /usr/bin/pip
Related