title: ImportError: No module named _______
body: <p>I'm learning the Python/Django/MySQL trinity to develop an ecommerce site using primarily Eclipse.  I've seen the issue I'm about to describe asked about 100 different ways on both StackOverflow and the internet abroad, but it seems every problem is unique enough that each solution doesn't work for me.</p>
  
  <p>In eclipse, I'm using some simple import statements at the beginning of a file called <strong>forms.py</strong> to import some django forms and my personal "Product" class, like so:</p>
  
  <pre><code>from django import forms
  from ecomstore.catalog.models import Product
  </code></pre>
  
  <p>And already the problem has arose: Eclipse is showing an "Unresolved import: Product" warning on the line, referencing "Product."  When I run: </p>
  
  <pre><code>python manage.py validate
  </code></pre>
  
  <p>in the command line, I receive the titular error: "ImportError: No module named catalog," but I named it <strong>_</strong> because this error is cropping up on all of my imports from my catalog "module."</p>
  
  <p>Now I am definitely a beginner in the area of Python, so I assume I'm missing something obvious.  In eclipse, I have of course set my main "ecomstore" directory to be the project source, which as I understand it adds the "ecomstore" to the PYTHONPATH, thus allowing me to reference items within.  The relevant directory structure, to further illustrate the points:</p>
  
  <p>-ecomstore<br/>
    ----<strong>+manage.py</strong><br/>
    ----some other directories<br/>
    ----catalog<br/>
      -------<strong>+models.py</strong><br/>
      -------<strong>+forms.py</strong> &lt;--active file calling for the import<br/>
    ----ecomstore &lt;--actual project folder, contains settings.py, etc.<br/>
      -------<strong>+settings.py</strong></p>
  
  <p>Sorry for my terminology being off, I'm still transitioning over from Java and it is taking some time to learn the jargon.</p>
  
  <p>I point out that my "project folder" has the same name as the root folder of the project because I saw a few problems arising from same-named directories, but even after I changed the root-level directory to "test," the import was still failing so I ruled it out, but maybe I was wrong to do so.  Also, notice that forms.py is in the same directory as models.py, which is the file that contains my "Product" class...shouldn't that mean that, even IF my source folder setup in Eclipse was failing to add itself to PYTHONPATH, the import should STILL work because Python will try to load from the "" directory, aka the one from which the import is being called?  I'm sure my logic is flawed somewhere, which is why I've come asking for help.</p>
  
  <p>In case it will help, here is the relevant contents of models.py, because maybe the problem is in my setup of that file instead, though, like I said, this problem is occurring in several location throughout the project, though ONLY with imports from "catalog."</p>
  
  <pre><code>class Product(models.Model):
  name = models.CharField(max_length=50)
  slug = models.SlugField(max_length=50, 
                          unique=True,
                          help_text='Unique value for product page URL, created from name.')
  brand = models.CharField(max_length=50)
  sku = models.CharField(max_length=50)
  price = models.DecimalField(max_digits=9,
                              decimal_places=2,)
  old_price = models.DecimalField(max_digits=9,
                                  decimal_places=2,
                                  blank=True,default=0.00)
  image = models.CharField(max_length=50)
  description = models.TextField()
  is_active = models.BooleanField(default=True)
  is_bestseller = models.BooleanField(default=False)
  is_featured = models.BooleanField(default=False)
  meta_keywords = models.CharField("Meta Keywords",
                                   max_length=255,
                                   help_text='Comma-delimited set of SEO keywords for meta tag')
  meta_description = models.CharField("Meta Description",
                                      max_length=255,
                                      help_text='Content for description meta tag')
  created_at = models.DateTimeField(auto_now_add=True)
  updated_at = models.DateTimeField(Auto_now=True)
  categories = models.ManyToManyField(Category)
  
  class Meta:
      db_table = 'products'
      ordering = ['-created_at']
  
  def __unicode__(self):
      return self.name
  
  @models.permalink
  def get_absolute_url(self):
      return ('catalog_product',(), { 'product_slug': self.slug })
  
  def sale_price(self):
      if self.old_price &gt; self.price:
          return self.price
      else:
          return None
  </code></pre>
  
  <p><strong>EDIT 1</strong><br/>
  I forgot to mention, I have tried removing "ecomstore" from "ecomstore.catalog.models" but, while that cures the Eclipse error, the validation error remains the same.</p>
  
  <p><strong>EDIT 2</strong><br/>
  I opened up a command line and printed my sys.path to see what was in there normally.  The usual C:\Python27 things were there, but nothing referencing ecomstore...I assumed manage.db was appending it for me, since the book I am using never told me to deal with sys.path...is this possibly my error?  How exactly does "python manage.db validate" know to look in my root ecomstore folder?  By virtue of its location in the root folder perhaps?</p>
  
  <p><strong>EDIT 3</strong><br/>
  Somewhere in all this fiddling attempting to fix the problem, the server itself got completely caught on the "ImportError: No module named catalog."  Now if I try to do ANYTHING - even so much as just <code>runserver</code>, it throws the error.</p>
  
  <p><strong>EDIT 4</strong><br/>
  Below is my manage.py, located in my root ecomstore directory.  I have left it unedited since it was created by django, but I figure I'll add it in case there is something unusual with my django installation perhaps.</p>
  
  <pre><code>#!/usr/bin/env python
  import os
  import sys
  
  if __name__ == "__main__":
      os.environ.setdefault("DJANGO_SETTINGS_MODULE", "ecomstore.settings")
  
      from django.core.management import execute_from_command_line
  
      execute_from_command_line(sys.argv)
  </code></pre>
  
  <p>And now, the lengthy settings.py, which I have of course edited while working on the project.  This is located in the ecomstore directory WITHIN the root ecomstore project directory (see the above directory map, which I am now adding the settings.py file to.</p>
  
  <pre><code># Django settings for ecomstore project.
  
  DEBUG = True
  TEMPLATE_DEBUG = DEBUG
  
  ADMINS = (
      # ('Your Name', 'your_email@example.com'),
  )
  
  MANAGERS = ADMINS
  
  DATABASES = {
      'default': {
          'ENGINE': 'django.db.backends.mysql', # Add 'postgresql_psycopg2', 'mysql', 'sqlite3' or 'oracle'.
          'NAME': 'ecomstore',                      # Or path to database file if using sqlite3.
         ### EDITED OUT USER CREDENTIALS FOR STACK OVERFLOW ###
          'HOST': '',                      # Empty for localhost through domain sockets or '127.0.0.1' for localhost through TCP.
          'PORT': '',                      # Set to empty string for default.
      }
  }
  
  import os
  #hack to accommodate Windows
  CURRENT_PATH = os.path.abspath(os.path.dirname(__file__).decode('utf-8')).replace('\\', '/')
  
  # Hosts/domain names that are valid for this site; required if DEBUG is False
  # See https://docs.djangoproject.com/en/1.5/ref/settings/#allowed-hosts
  ALLOWED_HOSTS = []
  
  # Local time zone for this installation. Choices can be found here:
  # http://en.wikipedia.org/wiki/List_of_tz_zones_by_name
  # although not all choices may be available on all operating systems.
  # In a Windows environment this must be set to your system time zone.
  TIME_ZONE = 'America/Chicago'
  
  # Language code for this installation. All choices can be found here:
  # http://www.i18nguy.com/unicode/language-identifiers.html
  LANGUAGE_CODE = 'en-us'
  
  SITE_ID = 1
  
  # If you set this to False, Django will make some optimizations so as not
  # to load the internationalization machinery.
  USE_I18N = True
  
  # If you set this to False, Django will not format dates, numbers and
  # calendars according to the current locale.
  USE_L10N = True
  
  # If you set this to False, Django will not use timezone-aware datetimes.
  USE_TZ = True
  
  # Absolute filesystem path to the directory that will hold user-uploaded files.
  # Example: "/var/www/example.com/media/"
  MEDIA_ROOT = ''
  
  # URL that handles the media served from MEDIA_ROOT. Make sure to use a
  # trailing slash.
  # Examples: "http://example.com/media/", "http://media.example.com/"
  MEDIA_URL = ''
  
  # Absolute path to the directory static files should be collected to.
  # Don't put anything in this directory yourself; store your static files
  # in apps' "static/" subdirectories and in STATICFILES_DIRS.
  # Example: "/var/www/example.com/static/"
  STATIC_ROOT = ''
  
  # URL prefix for static files.
  # Example: "http://example.com/static/", "http://static.example.com/"
  STATIC_URL = '/static/'
  
  # Additional locations of static files
  STATICFILES_DIRS = (
      os.path.join(CURRENT_PATH, 'static'),
      # Put strings here, like "/home/html/static" or "C:/www/django/static".
      # Always use forward slashes, even on Windows.
      # Don't forget to use absolute paths, not relative paths.
  )
  
  # List of finder classes that know how to find static files in
  # various locations.
  STATICFILES_FINDERS = (
      'django.contrib.staticfiles.finders.FileSystemFinder',
      'django.contrib.staticfiles.finders.AppDirectoriesFinder',
  #    'django.contrib.staticfiles.finders.DefaultStorageFinder',
  )
  
  # Make this unique, and don't share it with anybody.
  # Naturally, edited this out for Stack Overflow as well, never edited it though anyways.
  
  # List of callables that know how to import templates from various sources.
  TEMPLATE_LOADERS = (
      'django.template.loaders.filesystem.Loader',
      'django.template.loaders.app_directories.Loader',
  #     'django.template.loaders.eggs.Loader',
  )
  
  MIDDLEWARE_CLASSES = (
      'django.middleware.common.CommonMiddleware',
      'django.contrib.sessions.middleware.SessionMiddleware',
      'django.middleware.csrf.CsrfViewMiddleware',
      'django.contrib.auth.middleware.AuthenticationMiddleware',
      'django.contrib.messages.middleware.MessageMiddleware',
      # Uncomment the next line for simple clickjacking protection:
      # 'django.middleware.clickjacking.XFrameOptionsMiddleware',
  )
  
  ROOT_URLCONF = 'ecomstore.urls'
  
  # Python dotted path to the WSGI application used by Django's runserver.
  WSGI_APPLICATION = 'ecomstore.wsgi.application'
  
  TEMPLATE_DIRS = (
      os.path.join(CURRENT_PATH, 'templates'),
      # Put strings here, like "/home/html/django_templates" or "C:/www/django/templates".
      # Always use forward slashes, even on Windows.
      # Don't forget to use absolute paths, not relative paths.
  )
  
  INSTALLED_APPS = (
      'django.contrib.auth',
      'django.contrib.contenttypes',
      'django.contrib.sessions',
      'django.contrib.sites',
      'ecomstore.catalog',
      'django.contrib.messages',
      'django.contrib.staticfiles',
      # Uncomment the next line to enable the admin:
      'django.contrib.admin',
      'catalog',
      # Uncomment the next line to enable admin documentation:
      # 'django.contrib.admindocs',
  )
  
  # A sample logging configuration. The only tangible logging
  # performed by this configuration is to send an email to
  # the site admins on every HTTP 500 error when DEBUG=False.
  # See http://docs.djangoproject.com/en/dev/topics/logging for
  # more details on how to customize your logging configuration.
  LOGGING = {
      'version': 1,
      'disable_existing_loggers': False,
      'filters': {
          'require_debug_false': {
              '()': 'django.utils.log.RequireDebugFalse'
          }
      },
      'handlers': {
          'mail_admins': {
              'level': 'ERROR',
              'filters': ['require_debug_false'],
              'class': 'django.utils.log.AdminEmailHandler'
          }
      },
      'loggers': {
          'django.request': {
              'handlers': ['mail_admins'],
              'level': 'ERROR',
              'propagate': True,
          },
      }
  }
  </code></pre>
  
  <p>I believe I have only edited TEMPLATE_DIRS, STATICFILES_DIRS, and INSTALLED_APPS at this point, as should be plainly obvious to everyone, but here it all is nevertheless.</p>
  
  <p><strong>EDIT 5</strong><br/>
  I have solved at least part of the problem, and isolated the issue.  By removing both <code>ecomstore.catalog</code> and <code>catalog</code> from my <code>INSTALLED_APPS</code>, I've managed to get manage.py functional again.  However, by adding either of those itesm back to INSTALLED_APPS causes different problems.  By reinserting <code>ecomstore.catalog</code> I get the <code>ImportError: No module named catalog</code>.  If I instead use <code>catalog</code>, I get this error: <code>TypeError: __init__() got an unexpected keyowrd argument 'Auto_now'.</code></p>
  
  <p>In addition, see below my sys.path, which being the beginner I am I may have bungled when setting the whole thing up in the first place.</p>
  
  <pre><code>&gt;&gt;&gt; print sys.path
  ['C:\\Users\\Sean\\Dropbox\\Website\\ecomstore', 
  'C:\\Python27\\lib\\site-packages\\distribute-0.6.35-py2.7.egg',     
  'C:\\Python27\\lib\\site-packages\\django_db_log-2.2.1-py2.7.egg',
  'C:\\Windows\\system32\\python27.zip', 
  'C:\\Python27\\DLLs', 'C:\\Python27\\lib', 
  'C:\\Python27\\lib\\plat-win', 
  'C:\\Python27\\lib\\lib-tk', 
  'C:\\Python27', 
  'C:\\Users\\Sean\\AppData\\Roaming\\Python\\Python27\\site-packages', 
  'C:\\Python27\\lib\\site-packages', 
  'C:\\Python27\\lib\\site-packages\\win32', 
  'C:\\Python27\\lib\\site-packages\\win32\\lib', 
  'C:\\Python27\\lib\\site-packages\\Pythonwin']
  </code></pre>