【发布时间】:2015-12-09 07:57:05
【问题描述】:
我的目录结构如下:
Chippa/
bin/
__init__.py
app.py
tests/
__init__.py
app_tests.py
tools.py
templates/
hello_form.html
index.html
layout.html
docs/
在我的app_tests.py 文件中,我有:
from nose.tools import *
from bin.app import app
from tests.tools import assert_response
当我尝试从tests 目录外部运行app_tests.py 时,在Chippa 目录内的测试目录之上一层,如下所示:
python tests/app_tests.py
我收到以下错误:
Traceback (most recent call last):
File "tests/app_tests.py", line 3, in <module>
from bin.app import app
ImportError: No module named bin.app
但我在bin 目录中确实有一个空的__init__.py,我认为这可以防止这个问题。我在这里想念什么?
【问题讨论】:
标签: python python-2.7 import python-module