First steps with python tutorial

I need help with getting the python example to work.
Here is what I am getting:

$  flyctl deploy
Update available 0.0.320-pre-1 -> v0.0.320.
Run "flyctl version update" to upgrade.
==> Verifying app config
--> Verified app config
==> Building image
Remote builder fly-builder-lively-violet-5174 ready
==> Creating build context
--> Creating build context done
==> Building image with Docker
--> docker host: 20.10.12 linux x86_64
[+] Building 45.7s (0/1)                                                                                 
[+] Building 1.8s (11/11) FINISHED                                                                       
 => [internal] load remote build context                                                            0.0s
 => copy /context /                                                                                 0.3s
 => [internal] load metadata for                                       0.8s
 => [1/8] FROM  0.0s
 => CACHED [2/8] RUN apt-get update && apt-get install -y     python3-pip     python3-venv     pyt  0.0s
 => CACHED [3/8] RUN mkdir -p /app                                                                  0.0s
 => CACHED [4/8] WORKDIR /app                                                                       0.0s
 => CACHED [5/8] COPY requirements.txt .                                                            0.0s
 => CACHED [6/8] RUN pip install -r requirements.txt                                                0.0s
 => [7/8] COPY . .                                                                                  0.3s
 => ERROR [8/8] RUN python collectstatic --noinput                                        0.3s
 > [8/8] RUN python collectstatic --noinput:
#11 0.275 python: can't open file '': [Errno 2] No such file or directory
Error failed to fetch an image or build from source: error building: executor failed running [/bin/sh -c python collectstatic --noinput]: exit code: 2

Can someone help, please?

There is workaround here.
But I’ll still reinforce that, as a getting started tutorial, it should… just work?


100% agree, the demo app should just work. seems linked to mis-detection of the demo app as django not flask

A similar problem also happens when you’re running a Django app not named demo, the generated dockerfile will run gunicorn demo.wsgi:application rather than gunicorn AppName.wsgi:application. It doesn’t automatically detect the App Name.

But since the Dockerfile is really simple I don’t see the point of not just using a personal custom one rather than letting it autodetect your stack

1 Like

Not sure if this will help anyone else, but I was having an issue with the collectstatic command and I found that in Django under DATABASES I had to remove the curly braces from the value following "default": .

E.G. the following line seems to work:
"default": dj_database_url.parse(os.environ.get("DATABASE_URL"), conn_max_age=600),

But the following line does not work:
"default": {dj_database_url.parse(os.environ.get("DATABASE_URL"), conn_max_age=600),}

I found this on a thread about Heroku: python - deploying django to heroku - Stack Overflow