title: uWSGI - ImportError: No module named os
body: <p>This is puzzling, because uWSGI works when running:</p>
  
  <pre><code>uwsgi --http :8003 --wsgi-file bigsky.wsgi
  </code></pre>
  
  <p>But doesn't work with:</p>
  
  <pre><code>uwsgi --ini uwsgi.ini --no-site
  </code></pre>
  
  <p>It returns this error:</p>
  
  <pre><code>Traceback (most recent call last):
    File "bigsky.wsgi", line 1, in &lt;module&gt;
      import os
  ImportError: No module named os
  </code></pre>
  
  <p>This is being deployed with:</p>
  
  <ul>
  <li>python 3.4</li>
  <li>django 1.8</li>
  <li>Centos 7</li>
  <li>uWSGI 2.0.11</li>
  </ul>
  
  <p>Here's the code:</p>
  
  <p><strong>uwsgi.ini:</strong></p>
  
  <pre><code>[uwsgi]
  # %d is the dir this configuration file is in
  
  socket = 127.0.0.1:8003
  chmod-socket = 666
  
  uid = bsdev
  gid = bsdev
  
  master = true
  enable-threads = true
  processes = 4
  
  # virtualenv
  home = /home/bsdev/.virtualenvs/bs_py34
  
  chdir = /www/django/releases/persistent/bsrs/python3/
  wsgi-file = project.wsgi
  
  env = DJANGO_SETTINGS_MODULE=project.settings.persistent
  
  # create a pidfile
  pidfile = /tmp/project-master.pid 
  harakiri = 10 # respawn processes taking more than 20 seconds
  max-requests = 5000 # respawn processes after serving 5000 requests
  
  # will be run via `supervisord` so don't need to daemonize
  # logto = /var/log/uwsgi/project.log
  logdate = true
  vacuum = true
  </code></pre>
  
  <p><strong>project.wsgi:</strong></p>
  
  <pre><code>import os
  import sys
  
  
  # python 3
  sys.path.append('/usr/local/bin/python3.4')
  sys.path.append('/usr/local/lib/python3.4/site-packages')
  
  # project
  sys.path.append('/www/django/releases/persistent/bsrs/python3')
  sys.path.append('/www/django/releases/persistent/bsrs/bsrs-django')
  sys.path.append('/www/django/releases/persistent/bsrs/bsrs-django/project')
  sys.path.append('/www/django/releases/persistent/bsrs/bsrs-django/project/project')
  
  
  # 1st instantiate wsgi
  from django.core.wsgi import get_wsgi_application
  _application = get_wsgi_application()
  
  # Add the app directories to the PYTHONPATH
  os.environ['DJANGO_SETTINGS_MODULE'] = 'project.settings.persistent'
  
  
  def application(environ, start_response):
      return _application(environ, start_response)
  </code></pre>
  
  <p><strong>Edit:</strong></p>
  
  <p>I am also getting this error message.  It says <em>Python version: 2.7.5</em>, but the Django App should be running in python 3.4.  Is this a possible issue?</p>
  
  <pre><code>Tue Sep 22 13:25:12 2015 - thunder lock: disabled (you can enable it with --thunder-lock)
  Tue Sep 22 13:25:12 2015 - uwsgi socket 0 bound to UNIX address /tmp/bigsky.sock fd 3
  Tue Sep 22 13:25:12 2015 - Python version: 2.7.5 (default, Jun 24 2015, 00:41:19)  [GCC 4.8.3 20140911 (Red Hat 4.8.3-9)]
  Tue Sep 22 13:25:12 2015 - Set PythonHome to /home/bsdev/.virtualenvs/bs_py34/
  Tue Sep 22 13:25:12 2015 - Python main interpreter initialized at 0x25258f0
  Tue Sep 22 13:25:12 2015 - python threads support enabled
  Tue Sep 22 13:25:12 2015 - your server socket listen backlog is limited to 100 connections
  Tue Sep 22 13:25:12 2015 - your mercy for graceful operations on workers is 60 seconds
  Tue Sep 22 13:25:12 2015 - mapped 363840 bytes (355 KB) for 4 cores
  Tue Sep 22 13:25:12 2015 - *** Operational MODE: preforking ***
  Traceback (most recent call last):
    File "./bigsky/wsgi.py", line 1, in &lt;module&gt;
      import os
  ImportError: No module named os
  </code></pre>