gunicorn command not found, but it's in my requirements.txt
I also have
Pipfile
andPipfile.lock
files
That's your problem: you're using two different tools that, partly, do the same thing.
If you have a Pipfile
and Pipfile.lock
, Heroku uses Pipenv to install your dependencies, and your requirements.txt
will be ignored.
In the absence of a Pipfile
and Pipfile.lock
, Heroku uses pip
to install dependencies from requirements.txt
.
Pick a single tool and use it everywhere. If you choose Pipenv, make sure all of your dependencies are reflected in your Pipfile
and Pipfile.lock
(e.g. by running pipenv install -r requirements.txt
), delete your requirements.txt
, and redeploy. If you want to use pip
, get rid of your Pipfile
and Pipfile.lock
.
gunicorn: command not found
You should RUN pip install
as root, without the --user
option.
If you run pip install --user
, it installs packages into ~/.local
. In Docker the $HOME
environment variable isn't usually defined, so this will install them into /.local
. If you looked inside the built image, you'd probably find a runnable /.local/bin/gunicorn
, but that /.local/bin
directory isn't on the $PATH
.
Typical use in Docker is to install Python packages into the "system" Python; the Docker image itself is isolation from other Pythons. This will put the *.py
files into somewhere like /usr/local/lib/python3.10/site-packages
, and the gunicorn
executable will be in /usr/local/bin
, which is on the standard $PATH
.
FROM python:3.10.5-alpine
ENV PYTHONDONTWRITEBYTECODE=1
ENV PYTHONUNBUFFERED=1
RUN adduser -D appuser
WORKDIR /home/appuser/
# but do not change USER yet
COPY --chown=appuser:appuser requirements.txt .
# Without --user option
RUN python -m pip install --no-cache-dir --disable-pip-version-check --requirement requirements.txt
# Change USER _after_ RUN pip install
USER appuser
COPY --chown=appuser:appuser . .
ENTRYPOINT [ "./entrypoint.sh" ]
Heroku + gunicorn not working (bash: gunicorn: command not found )
The issue seemed to fix itself after uninstalling all requirements remotely, and reinstalling them.
Related Topics
Changes in Import Statement Python3
How to Use CSS Selectors to Retrieve Specific Links Lying in Some Class Using Beautifulsoup
Move and Zoom a Tkinter Canvas with Mouse
What Are Python Pandas Equivalents for R Functions Like Str(), Summary(), and Head()
Set the Hardware Clock in Python
Interfacing Python and Torch7(Lua) via Shared Library
How to Rewrite Output in Terminal
Could Not Find or Load the Qt Platform Plugin "Xcb"
How to Know If a Grpc Server Is Available
Python Deepcopy and Shallow Copy and Pass Reference
Loop Through All Nested Dictionary Values
How to Send a Signal from a Python Program
Does R Have Function Startswith or Endswith Like Python
Gae " No Attribute 'Httpshandler' " Dev_Appserver.Py
Will Python Systemrandom/Os.Urandom Always Have Enough Entropy for Good Crypto