Run manage.py from AWS EB Linux instance
Solution 1:
How to run manage.py from AWS Elastic Beanstalk AMI.
- SSH login to Linux (
eb ssh
)- (optional may need to run
sudo su -
to have proper permissions)
- (optional may need to run
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>
Solution 2:
With the new version of Python paths seem to have changed.
- The app is in /var/app/current
- The virtual environment is in /var/app/venv/[KEY]
So the instructions are:
- SSH to the machine using
eb shh
- Check the path of your environment with ls
/var/app/venv/
. The only folder should be the[KEY]
for the next step - Activate the environment with
source /var/app/venv/[KEY]/bin/activate
- Execute the command
python3 /var/app/current/manage.py <command>
Of course Amazon can change it anytime.