title: Python + WSGI - Can't import my own modules from a directory?
body: <p>I'm new to Python and i have looked around on how to import my custom modules from a directory/ sub directories. Such as <a href="https://stackoverflow.com/questions/4142151/python-how-to-import-the-class-within-the-same-directory-or-sub-directory">this</a> and <a href="https://en.wikibooks.org/wiki/A_Beginner%27s_Python_Tutorial/Importing_Modules" rel="noreferrer">this</a>.</p>
  
  <p>This is my structure,</p>
  
  <pre><code>index.py
  __init__.py
  modules/
    hello.py
    HelloWorld.py
    moduletest.py
  </code></pre>
  
  <p>index.py,</p>
  
  <pre><code># IMPORTS MODULES
  import hello
  import HelloWorld
  import moduletest
  
  # This is our application object. It could have any name,
  # except when using mod_wsgi where it must be "application"
  def application(environ, start_response):
  
      # build the response body possibly using the environ dictionary
      response_body = 'The request method was %s' % environ['REQUEST_METHOD']
  
      # HTTP response code and message
      status = '200 OK'
  
      # These are HTTP headers expected by the client.
      # They must be wrapped as a list of tupled pairs:
      # [(Header name, Header value)].
      response_headers = [('Content-Type', 'text/plain'),
                         ('Content-Length', str(len(response_body)))]
  
      # Send them to the server using the supplied function
      start_response(status, response_headers)
  
      # Return the response body.
      # Notice it is wrapped in a list although it could be any iterable.
      return [response_body]
  </code></pre>
  
  <p><strong>init</strong>.py, </p>
  
  <pre><code>from modules import moduletest
  from modules import hello
  from modules import HelloWorld
  </code></pre>
  
  <p>modules/hello.py,</p>
  
  <pre><code>def hello():
      return 'Hello World from hello.py!'
  </code></pre>
  
  <p>modules/HelloWorld.py,</p>
  
  <pre><code># define a class
  class HelloWorld:
      def __init__(self):
          self.message = 'Hello World from HelloWorld.py!'
  
      def sayHello(self):
          return self.message
  </code></pre>
  
  <p>modules/moduletest.py,</p>
  
  <pre><code># Define some variables:
  numberone = 1
  ageofqueen = 78
  
  # define some functions
  def printhello():
      print "hello"
  
  def timesfour(input):
      print input * 4
  
  # define a class
  class Piano:
      def __init__(self):
          self.type = raw_input("What type of piano? ")
          self.height = raw_input("What height (in feet)? ")
          self.price = raw_input("How much did it cost? ")
          self.age = raw_input("How old is it (in years)? ")
  
      def printdetails(self):
          print "This piano is a/an " + self.height + " foot",
          print self.type, "piano, " + self.age, "years old and costing\
          " + self.price + " dollars."
  </code></pre>
  
  <p>But through the Apache WSGI, I get this error,</p>
  
  <blockquote>
    <p>[wsgi:error] [pid 5840:tid 828] [client 127.0.0.1:54621]     import
    hello [wsgi:error] [pid 5840:tid 828] [client 127.0.0.1:54621]
    ImportError: No module named hello</p>
  </blockquote>
  
  <p>Any idea what have I done wrong?</p>
  
  <p><strong>EDIT:</strong></p>
  
  <pre><code>index.py
  __init__.py
  modules/
    hello.py
    HelloWorld.py
    moduletest.py
    User/
      Users.py
  </code></pre>