Run manage.py from AWS EB Linux instance

后端 未结 3 1011
野的像风
野的像风 2020-11-29 21:30

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.

3条回答
  •  孤独总比滥情好
    2020-11-29 21:45

    TL;DR

    This answer assumes you have installed EB CLI. Follow these steps:

    1. Connect to your running instance using ssh.
    eb ssh 
    
    1. Once you are inside your environment, load the environment variables (this is important for database configuration)
    . /opt/python/current/env
    

    If you wish you can see the environment variables using printenv.

    1. Activate your virtual environment
    source /opt/python/run/venv/bin/activate
    
    1. Navigate to your project directory (this will depend on your latest deployment, so use the number of your latest deployment instead of XX)
    cd /opt/python/bundle/XX/app/
    
    1. Run the command you wish:
    python manage.py 
    

    Running example

    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
    

提交回复
热议问题