application folder not showing up on sys.path [Python]
Question: I have a web application that I am developing on my local machine. I copy over
the files to my server, and now my program will not run.

I examined the sys.path on both machines and on my server (where the code wont
run) i am missing the top-level directory from my path. I am using virtualenvs
on both machines. See the structure below

    
    
    myapplication/
      code/
        main.py
        db.py
      app/
        models.py
    

On my home machine, when I call `$ python2.7 main.py`, everything works fine.
I also see that `myapplication/` is on my path, as is `myapplication/app/`
(`print sys.path` from within `db.py`)

On the server, I am getting an import error `ImportError: No module named
app.models`

The import line in `db.py` is `from app import models`

Looking at the output of `print sys.path` on the server shows that the top
level `myapplication/` is missing from the path (only `myapplication/code`)

I have tried deleting and resyncing all of the `__init__.py` files and
deleting all of the `*.pyc` files

Any suggestions on why the top-level directory is getting omitted?


Answer: I'm not sure of the reason for the missing path in server. But what you can do
is, add the root directory in system path.

    
    
    sys.path.append(os.path.dirname(os.path.dirname(__file__)))
    

In your main.py

