I have the following structure:
project
├── sum_package
│ └── sum_module.py
├── testing.py
I try to access sum_module.py from testing.py in two different ways:
First:
from sum_package import sum_module
sum_module.great_summation(1,2)
Second:
import sum_package
sum_package.sum_module.great_summation(1,2)
First works, second doesn't:
AttributeError: module 'sum_package' has no attribute 'sum_module'
Can someone explain why?
EDIT: tried adding __init__.py into either/both the package folder / the project folder, does not help.
EDIT 2: so it seems like the problem is $PYTHONPATH. I've tried adding my src (project) directory as PYTHONPATH, like this:
export PYTHONPATH = "$PWD"
while in src, but I still get the same error. What else am I missing?:)