I\'m setting up a new dev environment on a Windows box, and after successfully installing Python and django, I cloned my repository on the new machine.
After running
Update for Python 3.X
While you can import modules without an __init__.py
file present,
The
__init__.py
files are required to make Python treat the directories as containing packages
https://docs.python.org/3/tutorial/modules.html
Without __init__.py
, the module has no __file__
attribute.
example/
|-- mod1
| `-- __init__.py
`-- mod2
>>> import mod1
>>> mod1.__file__
'/tmp/example/mod1/__init__.py'
>>> import mod2
>>> mod2.__file__
Traceback (most recent call last):
File "", line 1, in
AttributeError: module 'mod2' has no attribute '__file__'