I am doing a project on a Macbook, its system is OS X 10.11.5. I used Python 3.5 and had a directory like this
rec-par/
rec/
__init__.py
cle/
__init__.py
c.py
par/
__init__.py
b.py
util/
__init__.py
a.py
in a.py there is a import like
from rec.par.b import *
And it got a error like 'No module name rec.par , rec is not a package'. I have added the path 'rec-par' to the sys.path and in cle/c.py there is no error with the same import command.
I tried the methods given in Question How to fix "Attempted relative import in non-package" even with __init__.py,
used python3 -m a.py . But it didn't work.
Is there anything I missing here?
OK, I had solved this problem. In the directory util/__pycache__
There was a file par.cpython-35.py which had the same name with the directory package. This caused a confusion. After it been deleted , The problem solved.
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