Your answer is one click away!
I have a folder structure like this
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 from done.test1 import Tries ImportError: No module named done.test1
I am not able to import modules from the nested folder. Is there any way to do this.
Edit:
After Salva's answer I changed my structure like this
. ├── check.py |--__init__.py(no content) └── done ├── __init__.py(no content) └── test1 └── __init__.py <-- this files contains your Tries class
Same error is thrown now also.
Try to import package
done first
import done
If it doesn't work, probably you are running script from different folder than you specified (in this case
main_folder)
From logs it seems like you are using IPython, in this case try to add your folder as module path
import sys sys.path.append('path/to/your/main_folder') import done