python - Importing modules from nested folder -
this question has answer here:
- import module relative path 20 answers
i have folder structure
main_folder | |--done | | | |--test1 | |--__init__.py | |---check.py
__init__.py:
class tries(object): def __init__(self): print "test"
check.py:
from done.test1 import tries tries()
error:
--------------------------------------------------------------------------- importerror traceback (most recent call last) <ipython-input-8-10953298e1df> in <module>() ----> 1 done.test1 import tries importerror: no module named done.test1
i not able import modules nested folder. there way this.
edit:
after salva's answer changed structure
. ├── check.py |--__init__.py(no content) └── done ├── __init__.py(no content) └── test1 └── __init__.py <-- files contains tries class
same error thrown also.
you need file __init__.py
in each directory want considered package need in both directories:
. ├── check.py └── done ├── __init__.py └── test1 └── __init__.py <-- files contains tries class
Comments
Post a Comment