Pip install -e packages don't appear in Docker Pip install -e packages don't appear in Docker python python

Pip install -e packages don't appear in Docker


I ran into a similar issue, and one possible way that the problem can appear is from:

WORKDIR /usr/src/app

being set before pip install. pip will create the src/ directory (where the package is installed) inside of the WORKDIR. Now all of this shouldn't be an issue since your app files, when copied over, should not overwrite the src/ directory.

However, you might be mounting a volume to /usr/src/app. When you do that, you'll overwrite the /usr/src/app/src directory and then your package will not be found.

So one fix is to move WORKDIR after the pip install. So your Dockerfile will look like:

FROM python:2.7RUN mkdir -p /usr/src/appCOPY requirements.txt /usr/src/app/RUN pip install -r /usr/src/app/requirements.txtCOPY . /usr/src/appWORKDIR /usr/src/app

This fixed it for me. Hopefully it'll work for you.


@mikexstudios is correct, this happens because pip stores the package source in /usr/src/app/src, but you're mounting a local directory over top of it, meaning python can't find the package source.

Rather than changing the position of WORKDIR, I solved it by changing the pip command to:

pip install -r requirements.txt --src /usr/local/src

Ether approach should work.


If you are recieving a similar error when installing a git repo from a requirements file under a dockerized container, you may have forgotten to install git.

Here is the error I recieved:

Downloading/unpacking CMRESHandler from git+git://github.com/zigius/python-elasticsearch-logger.git (from -r /home/ubuntu/requirements.txt (line 5))Cloning git://github.com/zigius/python-elasticsearch-logger.git to /tmp/pip_build_root/CMRESHandlerCleaning up...Cannot find command 'git'Storing debug log for failure in /root/.pip/pip.logThe command '/bin/sh -c useradd ubuntu -b /home && echo "ubuntu     ALL     = NOPASSWD: ALL" >> /etc/sudoers             && chown -R ubuntu:ubuntu /home/ubuntu && pip install -r /home/ubuntu/requirements.txt returned a non-zero code: 1

Here is an example Dockerfile that installs git and then installs all requirements:

FROM python:3.5-slimRUN apt-get update && apt-get install -y --no-install-recommends git \ADD . /code       WORKDIR /codeRUN pip install --upgrade pip setuptools && pip install -r /home/ubuntu/requirements.txt

Now you can use git packages in your requirements file in a Dockerized environment