I have a problem with python module import. I installed django (this can be any other module). I use this module:
from django.template import Context
# other imports
# use Context
I have a folder in my application named "utilities". In this folder I created a file "django.py" - this file contains some functions to work with django. So I import django in my module and I get error: File "...\utilities\django.py", line 1, in from django.template import Context ImportError: No module named template
Use namepaces, create a
__init__.py
in your utilities directory, so that it is package and then doimport utilities.django
. Btw, it is bad practice to name your module the same as std libraries or the name of package you know you are going to use. You never know when you are going to confuse yourself with which module to use.You will have to enable absolute imports at the top of the file:
You will then have to convert the imports in the module into absolute or relative imports as appropriate.