title: No module named markdown App Engine
body: <p>My directory structure in app engine is like this : </p>
  
  <pre><code>project 
      app.yaml
      main.py
      lib
        markdown
          markdown_files 
  </code></pre>
  
  <p>Markdown is being imported in <code>main.py</code> by <code>from lib.markdown import markdown </code>. At this point dev server is starting to give me the following stack trace. I am wondering what's going wrong here !? I do have an <strong>init</strong>.py in lib.</p>
  
  <pre><code>Traceback (most recent call last):
    File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/tools/dev_appserver.py", line 2769, in _HandleRequest
      self._Dispatch(dispatcher, self.rfile, outfile, env_dict)
    File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/tools/dev_appserver.py", line 2654, in _Dispatch
      base_env_dict=env_dict)
    File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/tools/dev_appserver.py", line 683, in Dispatch
      base_env_dict=base_env_dict)
    File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/tools/dev_appserver.py", line 1718, in Dispatch
      self._module_dict)
    File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/tools/dev_appserver.py", line 1622, in ExecuteCGI
      reset_modules = exec_script(config, handler_path, cgi_path, hook)
    File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/tools/dev_appserver.py", line 1310, in ExecuteOrImportScript
      exec module_code in script_module.__dict__
    File "/Users/nomadali/jeeqs/git/src/jeeqs.py", line 26, in &lt;module&gt;
      from lib.markdown import markdown
    File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/tools/dev_appserver_import_hook.py", line 676, in Decorate
      return func(self, *args, **kwargs)
    File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/tools/dev_appserver_import_hook.py", line 1845, in load_module
      return self.FindAndLoadModule(submodule, fullname, search_path)
    File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/tools/dev_appserver_import_hook.py", line 676, in Decorate
      return func(self, *args, **kwargs)
    File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/tools/dev_appserver_import_hook.py", line 1717, in FindAndLoadModule
      description)
    File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/tools/dev_appserver_import_hook.py", line 676, in Decorate
      return func(self, *args, **kwargs)
    File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/tools/dev_appserver_import_hook.py", line 1660, in LoadModuleRestricted
      description)
    File "/Users/nomadali/jeeqs/git/src/lib/markdown/__init__.py", line 161, in &lt;module&gt;
      import preprocessors
    File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/tools/dev_appserver_import_hook.py", line 676, in Decorate
      return func(self, *args, **kwargs)
    File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/tools/dev_appserver_import_hook.py", line 1845, in load_module
      return self.FindAndLoadModule(submodule, fullname, search_path)
    File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/tools/dev_appserver_import_hook.py", line 676, in Decorate
      return func(self, *args, **kwargs)
    File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/tools/dev_appserver_import_hook.py", line 1717, in FindAndLoadModule
      description)
    File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/tools/dev_appserver_import_hook.py", line 676, in Decorate
      return func(self, *args, **kwargs)
    File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/tools/dev_appserver_import_hook.py", line 1660, in LoadModuleRestricted
      description)
    File "/Users/nomadali/jeeqs/git/src/markdown/preprocessors.py", line 11, in &lt;module&gt;
  ImportError: No module named markdown
  INFO     2012-02-20 19:53:02,506 dev_appserver.py:2884] "GET /favicon.ico HTTP/1.0" 500 -
  </code></pre>
  
  <p><strong>Update1</strong></p>
  
  <p>I believe this question is a dupe of <a href="https://stackoverflow.com/questions/6208369/import-python-module-with-pyimport-importmoduleex-for-a-gedit-plugin">Import Python module with PyImport_ImportModuleEx for a gedit plugin</a></p>
  
  <p>The answer:</p>
  
  <blockquote>
    <p>If you want to use markdown without modifying it then you're going to have to put it somewhere where the Python library expects it, such as in site-packages/. Otherwise, you will have to modify it to use relative imports instead of absolute imports.</p>
  </blockquote>
  
  <p><strong>Update 2</strong>
  I resolved this issue by modifying my sys.path in app engine:</p>
  
  <p>sys.path.append(os.path.join(os.path.dirname(<strong>file</strong>), 'lib'))</p>
  
  <p>Thanks to Murat for help, </p>