title: Cannot locate modules of Django App on AWS Elastic Beanstalk
body: <p>I'm trying to make a Django app run on AWS Elastic Beanstalk, but am stuck with what appears like it might be a PYTHONPATH or virtualenv problem, and I can't figure it out.</p>
  
  <p>When I try to load a page in my browser, I get the yellow Django error screen (I'm still in debug mode):</p>
  
  <pre><code>Exception Value: No module named views.rest
  Exception Location: /opt/python/current/app/project/urls.py in &lt;module&gt;, line 3
  Python Executable:  /opt/python/run/venv/bin/python
  Python Version: 2.7.5
  Python Path:    
  ['/opt/python/run/venv/lib/python2.7/site-packages',
   '/opt/python/current/app',
  ...
  </code></pre>
  
  <p>My urls.py imports are:</p>
  
  <pre><code>from django.conf.urls import patterns, include, url
  from django.contrib import admin
  from myapp.views.rest import *
  </code></pre>
  
  <p>If I ssh into the EC2 instance, the path looks right; <code>/opt/python/current/app</code> contains my application, including <code>/opt/python/current/app/myapp/views/rest.py</code>.</p>
  
  <p>My directory structure contains (there's more, too, of course):</p>
  
  <pre><code>app/
      .ebextensions/
          packages.config
          python.config
      .elasticbeanstalk/
          config
          optionsettings.myapp-deployment-env
      project/
          settings.py
      application.py
      myapp/
          views/
              rest.py
              views.py
              __init__.py
  </code></pre>
  
  <h3>In <code>__init__.py</code> I've got:</h3>
  
  <pre><code>from myapp.views.views import *
  from myapp.views.rest import *
  </code></pre>
  
  <p>The issue is not specific to these files though - if I add another import to urls.py that fails too, so it's like it's not finding the app at all.</p>
  
  <h3>In <code>packages.config</code> I've got:</h3>
  
  <pre><code>packages:
    yum:
      postgresql-devel: []
  </code></pre>
  
  <h3>In <code>python.config</code> I've got (in an attempt to load the virtualenv, which might not be necessary?)</h3>
  
  <pre><code>container_commands:
    00_activate:
      command: "source /opt/python/run/venv/bin/activate"
    01_make_admin_executable:
      command: "chmod +x scripts/createadmin.py"
      leader_only: true
    02_make_executable:
      command: "chmod +rx application.py"
      leader_only: true
    03_syncdb:
      command: "python manage.py syncdb --noinput"
      leader_only: true
    04_collectstatic:
      command: "python manage.py collectstatic --noinput"
  
  option_settings:
    - option_name: AWS_SECRET_KEY
      value: mykey
    - option_name: AWS_ACCESS_KEY_ID
      value: myaccesskeyid
    - option_name: application_stage
      value: "staging"
  </code></pre>
  
  <p>Happy to list the other config files if they're helpful. They do include the settings location but no specific reference to PYTHONPATH etc.</p>
  
  <pre><code>[aws:elasticbeanstalk:application:environment]
  DJANGO_SETTINGS_MODULE=project.settings
  </code></pre>
  
  <p>I've run <code>eb update</code> and <code>git aws.push</code>.</p>
  
  <p>Really struggling with this one! My first attempt at an AWS deployment so have obviously missed something important. Really appreciate the help if anyone knows what I've missed.</p>