I have a requirements.txt
file containing, amongst others:
Flask-RQ==0.2 -e git+https://token:[email protected]/user/repo.git#egg=repo
When I try to build a Docker container using Docker Compose, it downloads both packages, and install them both, but when I do a pip freeze
there is no sign of the -e
package. When I try to run the app, it looks as if this package hasn't been installed. Here's the relevant output from the build:
Collecting Flask-RQ==0.2 (from -r requirements.txt (line 3)) Downloading Flask-RQ-0.2.tar.gz Obtaining repo from git+https://token:[email protected]/user/repo.git#egg=repo (from -r requirements.txt (line 4)) Cloning https://token:[email protected]/user/repo.git to ./src/repo
And here's my Dockerfile
:
FROM python:2.7 RUN mkdir -p /usr/src/app WORKDIR /usr/src/app COPY requirements.txt /usr/src/app/ RUN pip install -r requirements.txt COPY . /usr/src/app
I find this situation very strange and would appreciate any help.
To install any packages, you first need to update the OS. Step 3: After you have updated the Docker Container, you can now install the Firefox and Vim packages inside it. You can now easily use these packages through the bash itself.
To do so, we can use the pip list -o or pip list --outdated command, which returns a list of packages with the version currently installed and the latest available. On the other hand, to list out all the packages that are up to date, we can use the pip list -u or pip list --uptodate command.
One of the most common problems with running Python tools like pip is the “not on PATH” error. This means that Python cannot find the tool you're trying to run in your current directory. In most cases, you'll need to navigate to the directory in which the tool is installed before you can run the command to launch it.
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.7 RUN mkdir -p /usr/src/app COPY requirements.txt /usr/src/app/ RUN pip install -r /usr/src/app/requirements.txt COPY . /usr/src/app WORKDIR /usr/src/app
This fixed it for me. Hopefully it'll work for you.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With