Python: Added Folder By Namespace Won’t Import…. How To Make A Namespace.

Ran into this last night and it was giving me some issues. Basically, I added a folder (unitTest) and then some .py files to it. So my folder structure is something like:


Now one would assume you could do this:

from python.unitTest.validation.validationTest import someTestMethod

Problem was that the IDE (PYCHARM PLUG) was telling that it couldn’t see the unitTest namespace. After some nerd rage and searching, turns out that Python by nature doesn’t assume .py files outside of the main folder structure “belong” to it. The fix is simple though, add a blank file to the folder. In my case, I added a blank file to the unitTestFolder. Then and only then would the above namespace actually work. Here’s something on the file