How to run manage.py
from AWS EB (Elastic Beanstalk) Linux instance?
If I run it from \'/opt/python/current/app\', it shows the below exception.
This answer assumes you have installed EB CLI. Follow these steps:
eb ssh <environment-name>
. /opt/python/current/env
If you wish you can see the environment variables using printenv
.
source /opt/python/run/venv/bin/activate
XX
)cd /opt/python/bundle/XX/app/
python manage.py <command_name>
Asumming that your environment name is my-env
, your latest deployment number is 13
, and you want to run the shell
command:
eb ssh my-env # 1
. /opt/python/current/env # 2
source /opt/python/run/venv/bin/activate # 3
cd /opt/python/bundle/13/app/ # 4
python manage.py shell # 5
With the new version of Python paths seem to have changed.
So the instructions are:
eb shh
/var/app/venv/
. The only folder should be the [KEY] for the next step/var/app/venv/[KEY]/bin/activate
python3 /var/app/current/manage.py <command>
Of course Amazon can change it anytime.
How to run manage.py from AWS Elastic Beanstalk AMI.
eb ssh
)
sudo su -
to have proper permissions)source /opt/python/run/venv/bin/activate
source /opt/python/current/env
cd /opt/python/current/app
python manage.py <commands>
Or, you can run command as like the below:
cd /opt/python/current/app
/opt/python/run/venv/bin/python manage.py <command>