[Fixed]-Django-admin.py and python path on EC2 Amazon Beanstalk


The message:

  File "manage.py", line 3, in <module>
    from django.core.management import execute_from_command_line
ImportError: No module named django.core.management

is not because your app is not in the PYTHONPATH but rather because it can’t find your django application at all. Meaning your site-packages directory is not in the PYTHONPATH.

Try to find the site-packages directory in your server and that should in the PYTHONPATH. I haven’t deployed a python app with Elastic Beanstalk but I believe it maybe using a python virtual environment. In which case you need to source your virtual environment before running python ./manage shell



You can add an option_name if you need to change PYTHONPATH, or set any environment variable in general.

In your .ebextensions/myapp-env.config file (or whatever your *.config is named):

  - option_name: PYTHONPATH
    value: /opt/python/ondeck/app/myapp:$PYTHONPATH

Leave a comment