As mopodo points out, your choice of filename is conflicting with Python's builtin code
module. So, it finds that module earlier in the include path, but then fails because (not surprisingly) it doesn't define the name application
to be imported.
I would strongly recommend renaming the file to something you can be sure is unique, such as bamboapp.py
- this should fix your issues.
If you're really attached to the name code.py
, however, you can probably make it work by subtly changing your wsgi.py
file to this:
import os
import sys
path = "/home/bambo/"
if not sys.path or sys.path[0] != path:
sys.path.insert(0, path)
from code import application
I should point out that with this approach any .py
files you have in this directory will hide Python builtins or system libraries, which could create serious headaches for you. You have control over which libraries you import, but you may break libraries that they import which is a lot harder to figure out.
In short, just rename to something unique - it'll make your life a lot easier.