I have a folder blimp with an __init__.py, models.py and views.py
When I import from outside the folder I use from blimp.models import .. but inside folder it gives an import error unless I use from models import ..
I was wondering why this is?
Thanks
When you are inside the folder and you do :
Python try to find
blimp/blimp/models.py. So it’s logic to have the error,Personally, I always configure correctly my PYTHONPATH in order to have generic import code (no specific python code to manipulate the PYTHON PATH).
To do this, I use virtualenv and virtualenvwrapper. When my virtualenv is enable :
After that, directory1 directory2 and directory3 are available in the PYTHONPATH.