How do I run a Python script that is part of an application I uploaded in an AWS SSH session?

久未见 提交于 2019-12-04 14:31:49
volent

To migrate your database the best is to use container_commands, they are commands that will run every time you deploy your application. There is a good example in the EBS documentation (Step 6) :

container_commands:
  01_syncdb:    
    command: "django-admin.py syncdb --noinput"
    leader_only: true

The reason why you're getting an ImportError is because EBS installs your packages in a virtualenv. Before running arbitrary scripts in your application in SSH, first change to the directory containing your (latest) code with

cd /opt/python/current

and then activate the virtualenv

source /opt/python/run/venv/bin/activate

and set the environment variables (that your script probably expects)

source /opt/python/current/env
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!