How do I execute manage.py in Google App Engine?
Solution 1:
Perhaps this is useful for someone else who encounters this. It is certainly advisable to use @George's answer for normal operation, but in a pinch you can shell into run a python command from App Engine. I recently had to for debugging purposes. I used the SSH access in App Engine -> Instances in the GCP Control Panel. In my case I was using the flex environment which runs docker inside an VM instance so there are a few steps.
- Go to GCP -> Engine -> Instances and SSH into an instance.
- Once an SSH session is running make sure your containers are running:
docker ps
. In my case my Django app was running in a container calledgaeapp
. - Docker exec into the container:
docker exec -it gaeapp /bin/bash
- If that command works you are now in a running container for your app. Run your command. For example:
python manage.py help
NOTE: These environments should be considered ephemeral and you should not make this part of any consistent workflow. When an App Engine instance is changed from debug mode back to normal operation it is very likely it will be destroyed and a new instance will replace it. This means any files generated will be lost. It also means any files generated will only exist on one of potentially many VM instances.
Solution 2:
You are supposed to run manage.py locally, in your development environment, to organize files in view of deployment, not once deployed on servers. You may gather more detail from the "Running Django in the App Engine Flexible Environment" online document.