-
-
Notifications
You must be signed in to change notification settings - Fork 322
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ModuleNotFoundError: No module named 'app' #225
Comments
I've just had a similar error. My source code directory is app.
OR
|
@JaeHyunL nailed it! Thank you, whoever you are! I am using the Heroku container stack. My Dockerfile looked like this: FROM tiangolo/uvicorn-gunicorn-fastapi:python3.11-slim
COPY ./requirements.txt /app/requirements.txt
RUN pip install --no-cache-dir --upgrade -r /app/requirements.txt
COPY ./app /app I changed it to this (appended
Also, FWIW, my heroku.yml file looks like this: build:
docker:
web: Dockerfile
run:
web: sh /start.sh |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi, the error as mentioned in the title is thrown when running the container. Below I tried to describe my setup in detail.
I have setup everything exactly as described in the readme. Therefore, this is how my Dockerfile looks like.
my directory structure is as follows.
then, in the
app/main.py
I am trying to importuser
from theapi
-directory by doing:from app.api import user
When running the container, the following error is thrown.
ModuleNotFoundError: No module named 'app'
This is probably because
app
is not in the PYTHONPATH. I have tried to add it to the Dockerfile, but this did not help.I want to keep the structure and the way of importing it as is as it is also needed by my test setup.
How can I fix this? The problem has probably a very trivial solution, but I am currently stuck.
Thanks in advance
The text was updated successfully, but these errors were encountered: