I know this should be easy and I know that other people online have asked this question, but I feel like I understand all of their answers and the concepts, yet my import is still throwing errors.
I have this directory structure
root/myPackage/
root/tests/test_1.py
in test_1.py I have:
import myPackage
...
I am running on the command line from the root:
$ pytest tests OR python tests/test_1.py
...just anything to get this script to run really. I've used pytest and have run python scripts before
and I keep getting the
No module named 'myPackage' error
I thought if I run the test from the root I would still be able to access myPackage... this is really contradicting my previous understanding and the internet... send help if you know why I'm getting importing errors.
ALSO, when I take the test_1.py out of the tests directory and run it from the root it works without errors. So this structure works
root/myPackage/
root/test_1.py
myPackage/__init__.pymust exist.root/tests/__init__.py?