App.py包含语句
from Blog.Views import Home
因此
Blog需要位于Python搜索模块(
sys.path)的目录列表中。可以各种方式安排。
- 由于您使用来启动应用程序
python start.py
,因此包含的目录start.py
会自动添加到搜索路径中。所以你可以改变from Blog.Views import Home
至
from Views import Home
另一种选择是将目录上移
start.py
一个级别Blog
。然后,当您调用时python start.py
,包含的目录start.py
也将是包含的目录Blog
。所以Python会Blog
在执行时找到from Blog.Views ...
最后,您可以将
Blog
目录添加到PYTHONPATH环境变量中。



