title: apache2 mod_wsgi bottlepy NameError: name 'os' is not defined
body: <p>I am trying to use apache2 mod_wsgi to deploy bottle.py web application.</p>
  
  <p>I followed the instruction below:</p>
  
  <p><a href="http://bottlepy.org/docs/dev/deployment.html#apache-mod-wsgi" rel="nofollow">http://bottlepy.org/docs/dev/deployment.html#apache-mod-wsgi</a></p>
  
  <p>Added a file /var/www/yourapp/app.wsgi:</p>
  
  <pre><code># Change working directory so relative paths (and template lookup) work again
  os.chdir(os.path.dirname(__file__))
  
  import bottle
  # ... build or import your bottle application here ...
  # Do NOT use bottle.run() with mod_wsgi
  application = bottle.default_app()
  </code></pre>
  
  <p>I added a file yourapp.py into /var/www/yourapp/:</p>
  
  <pre><code>from bottle import route, run, template
  
  @route('/hello/:name')
  def index(name='World'):
      return template('&lt;b&gt;Hello {{name}}&lt;/b&gt;!', name=name)
  </code></pre>
  
  <p>Am I doing the right thing?</p>
  
  <p>I get a Http 500 error, and found some error inside the log:</p>
  
  <pre><code>[Fri Feb 22 15:03:38 2013] [error] [client 192.168.0.104]     os.chdir(os.path.dirname(__file__))
  [Fri Feb 22 15:03:38 2013] [error] [client 192.168.0.104] NameError: name 'os' is not defined
  ke@dslds /var/log/apache2 $  NameError: name 'os' is not definedNameError: name 'os' is not defined
  </code></pre>