Possible Duplicate:
How to import the src from the tests module in python
I want to call another module which is located in another dir. My code structor is
flask_beginner/
app.py
models/
__init__.py
user.py
tests/
__init__.py
user_test.py
I want to call user module from user_test.py. My user_test.py is like this..
import models.user
....
But it raise error that no module named models.user
Do you have any idea?
My Python Version is 2.7.2.(with virtualenv)
Thanks in advance.
If you are running user_test.py from the tests directory it will not be able to find the models package. However if you run it from flask_beginner directory it will be able to find the module. The reason being the directory from which you are executing the scripts is appended to the python path and hence it can find all the modules in your project.