I recently discovered that a package which was installed with
$ pip install -e .
did not have an __init__.py file in a subpackage. Still, I could import it without problems. When I installed the same with
$ pip install .
I could not import the subpackage. Why?
(In case it matters: I use Python 3.6)
Folders with no __init__.py may be treated as part of an implicit namespace package. Unless you know what a namespace package is and specifically want one, you should still include __init__.py in your packages, but that's what's going on here.
With pip install -e ., pip installs a thing that tells Python to look directly in your original source folder for the package contents. When Python looks in your source folder, it finds the no-__init__.py folders.
With pip install ., pip only installs what setup.py says to install, and your setup.py does not say to install the no-__init__.py folders. Python looks in the installed version of the package, not your original source folder, and it does not find the no-__init__.py folders.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With