python - No module named -
i have python project structure: (this not real project, testing)
importtest importpersonstest\ importperson\ importperson.py runimportpersontest.py runimporttests.py
i want tests call each other. e.g : runimporttests.py calls method in runimportpersontest.py, , runimportpersontest.py calls method importperson.py
runimportpersontest:
import os import sys sys.path.insert(0, os.getcwd() + "../../../") importperson import importperson
runimporttests
import os import sys sys.path.insert(0, os.getcwd() + "../../") importpersonstest import runimportspersontest
i have success when run importperson.py , runimportpersontest.py, when try run runimporttests error :
traceback (most recent call last): file "xxx\liclipse workspace\systemtest\importtest\runimporttests.py", line 4, in <module> importpersonstest import runimportspersontest file "xxx\liclipse workspace\systemtest\importtest\importpersonstest\runimportspersontest.py", line 4, in <module> importperson import importperson importerror: no module named 'importperson'
any suggestions?
edit
new structure
importtest importpersonstest\ importperson\ importperson.py __init__.py runimportpersontest.py __init__.py runimporttests.py __init__.py
looks don't have __init__.py
files in project. python needs files able import modules folders. news is, easy make: of time, don't need in them, have exist.
see: https://docs.python.org/2/tutorial/modules.html#packages
Comments
Post a Comment