I have a flask app with the following structure (using a shared virtual environment):
|-Directory
|----venv/lib/python2.7/site-packages/example-package
|----------module.py
|----app
|----------static
|----------templates
|----------models.py
|--------------...
I need to access some classes in my app/models.py module within the virtual environment directory, for example as per the above, I need to do the following in venv/lib/python2.7/site-packages/example-package/module.py
from models import TestClass
However, I keep getting a 'ImportError: No module named models' error, even when I try setting the path to the models.py module.
I've tried:
path = 'absolute path to models'
import os
os.chdir(path)
(I also get an error here about 'config not found)
and,
import sys
sys.path.append('absolute path to models')
with similar results
The app works fine otherwise, but I need to import the respective module.