title: ImportError: No module named 'settings'
body: <p>I have two versions of python installed 2.7 and 3.4 and created a virtualenv and assigned python34 to that new environment. When I activate that virtualenv and run <code>python manage.py runserver</code> then I get the following output.</p>
  
  <pre><code>(casenv) C:\pyprojects\focus\site&gt;python manage.py runserver
  Traceback (most recent call last):
    File "manage.py", line 22, in &lt;module&gt;
      execute_from_command_line(sys.argv)
    File "C:\virtualenvs\casenv\lib\site-packages\django\core\management\__init__.py", line 367, in execute_from_command_line
      utility.execute()
    File "C:\virtualenvs\casenv\lib\site-packages\django\core\management\__init__.py", line 341, in execute
      django.setup()
    File "C:\virtualenvs\casenv\lib\site-packages\django\__init__.py", line 27, in setup
      apps.populate(settings.INSTALLED_APPS)
    File "C:\virtualenvs\casenv\lib\site-packages\django\apps\registry.py", line 108, in populate
      app_config.import_models(all_models)
    File "C:\virtualenvs\casenv\lib\site-packages\django\apps\config.py", line 199, in import_models
      self.models_module = import_module(models_module_name)
    File "C:\virtualenvs\casenv\lib\importlib\__init__.py", line 104, in import_module
      return _bootstrap._gcd_import(name[level:], package, level)
    File "&lt;frozen importlib._bootstrap&gt;", line 2231, in _gcd_import
    File "&lt;frozen importlib._bootstrap&gt;", line 2214, in _find_and_load
    File "&lt;frozen importlib._bootstrap&gt;", line 2203, in _find_and_load_unlocked
    File "&lt;frozen importlib._bootstrap&gt;", line 1200, in _load_unlocked
    File "&lt;frozen importlib._bootstrap&gt;", line 1129, in _exec
    File "&lt;frozen importlib._bootstrap&gt;", line 1448, in exec_module
    File "&lt;frozen importlib._bootstrap&gt;", line 321, in _call_with_frames_removed
    File "C:\pyprojects\focus\site\general\models.py", line 8, in &lt;module&gt;
      from focus2.util import HashedPk
    File "C:\pyprojects\focus\site\focus2\util.py", line 3, in &lt;module&gt;
      from settings import Hasher
  ImportError: No module named 'settings'
  </code></pre>
  
  <p>File - manage.py</p>
  
  <pre><code>#!/usr/bin/env python
  import os
  import sys
  
  if __name__ == "__main__":
      os.environ.setdefault("DJANGO_SETTINGS_MODULE", "focus2.settings")
      try:
          from django.core.management import execute_from_command_line
      except ImportError:
          # The above import may fail for some other reason. Ensure that the
          # issue is really that Django is missing to avoid masking other
          # exceptions on Python 2.
          try:
              import django
          except ImportError:
              raise ImportError(
                  "Couldn't import Django. Are you sure it's installed and "
                  "available on your PYTHONPATH environment variable? Did you "
                  "forget to activate a virtual environment?"
              )
          raise
      execute_from_command_line(sys.argv)
  </code></pre>
  
  <p>The first 2 lines from utils.py -- </p>
  
  <pre><code>from django.utils.html import strip_tags, escape
  from settings import Hasher
  </code></pre>
  
  <p>The project directory structure is</p>
  
  <pre><code>├───focus
  │   ├───data_dumps
  │   ├───notes
  │   ├───setup
  │   └───site(main project folder)
  |       └───static
  |       └───general
  |       └───pro
  |           └───models
  |               +--__init__.py
  |               +--plans.py
  │       └───focus2
  │           └───templates
  |           +--__init__.py
  │           +--settings.py
  │           +--util.py            
  │           +--wsgi.py
  │       +--manage.py
  </code></pre>
  
  <p>I have the same code and dir structure which runs well with virtualenv python2.7. The difference between python27 env and python34 env is that I have installed mysql-python module in 27 and mysqlclient in 34.</p>
  
  <p>Pip freeze command from python34 env.</p>
  
  <pre><code>(casenv) C:\virtualenvs\casenv&gt;pip freeze
  certifi==2017.7.27.1
  chardet==3.0.4
  defusedxml==0.5.0
  Django==1.10.1
  django-ajax-selects==1.5.0
  django-allauth==0.32.0
  django-crispy-forms==1.6.1
  easy-thumbnails==2.3
  hashids==1.1.0
  idna==2.5
  lxml==3.7.3
  mysqlclient==1.3.10
  oauthlib==2.0.2
  Pillow==3.3.1
  PyMySQL==0.7.11
  python3-openid==3.1.0
  requests==2.18.3
  requests-oauthlib==0.8.0
  urllib3==1.22
  </code></pre>
  
  <p>Pip freeze command from python27 virtualenv. I don't get any error while running this venv.</p>
  
  <pre><code>(testvenv27) C:\virtualenvs\testvenv27&gt;pip freeze
  Django==1.10.1
  django-ajax-selects==1.5.0
  django-allauth==0.27.0
  django-crispy-forms==1.6.0
  easy-thumbnails==2.3
  hashids==1.1.0
  lxml==3.4.2
  MySQL-python==1.2.5
  oauthlib==2.0.0
  Pillow==3.3.1
  python-openid==2.2.5
  requests==2.9.1
  requests-oauthlib==0.6.1
  </code></pre>
  
  <p>The sys.path command output--</p>
  
  <pre><code>&gt;&gt;&gt; import sys
  &gt;&gt;&gt; print(sys.path)
  ['', 'C:\\WINDOWS\\SYSTEM32\\python34.zip', 'C:\\virtualenvs\\casenv\\DLLs', 'C:\\virtualenvs\\casenv\\lib', 'C:\\virtualenvs\\casenv\\Scripts', 'c:\\python34\\Lib', 'c:\\python34\\DLLs', 'C:\\virtualenvs\\casenv', 'C:\\virtualenvs\\casenv\\lib\\site-packages']
  </code></pre>
  
  <p>Any help is highly appreciated.</p>