ImportError: module 'app' has no attribute 'secure'

来源:7-3 使用ViewModel处理书籍数据 下

慕桂英5369657

2019-04-25

项目下载后启动不了,报这个错,已安装这个secure

FLASK_APP = …/coding-194/fisher.py
FLASK_ENV = development
FLASK_DEBUG = 0
In folder D:/pythonTool/fisherTest
D:\pythonTool\coding-194\venv\Scripts\python.exe -m flask run

  • Serving Flask app “…/coding-194/fisher.py”
  • Environment: development
  • Debug mode: off
    Usage: python -m flask run [OPTIONS]

Error: While importing “fisher”, an ImportError was raised:

Traceback (most recent call last):
File “D:\pythonTool\coding-194\venv\lib\site-packages\werkzeug\utils.py”, line 557, in import_string
return getattr(module, obj_name)
AttributeError: module ‘app’ has no attribute ‘secure’

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File “D:\pythonTool\coding-194\venv\lib\site-packages\werkzeug\utils.py”, line 559, in import_string
raise ImportError(e)
ImportError: module ‘app’ has no attribute ‘secure’

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File “D:\pythonTool\coding-194\venv\lib\site-packages\flask\cli.py”, line 235, in locate_app
import(module_name)
File “D:\pythonTool\coding-194\fisher.py”, line 10, in
app = create_app()
File “D:\pythonTool\coding-194\app_init_.py”, line 20, in create_app
app.config.from_object(‘app.secure’)
File “D:\pythonTool\coding-194\venv\lib\site-packages\flask\config.py”, line 170, in from_object
obj = import_string(obj)
File “D:\pythonTool\coding-194\venv\lib\site-packages\werkzeug\utils.py”, line 564, in import_string
ImportStringError, ImportStringError(import_name, e), sys.exc_info()[2]
File “D:\pythonTool\coding-194\venv\lib\site-packages\werkzeug_compat.py”, line 147, in reraise
raise value.with_traceback(tb)
File “D:\pythonTool\coding-194\venv\lib\site-packages\werkzeug\utils.py”, line 559, in import_string
raise ImportError(e)
werkzeug.utils.ImportStringError: import_string() failed for ‘app.secure’. Possible reasons are:

  • missing init.py in a package;
  • package or module path not included in sys.path;
  • duplicated package or module name taking precedence in sys.path;
  • missing module, class, function or variable;

Debugged import:

  • ‘app’ found in ‘D:\pythonTool\coding-194\app\init.py’.
  • ‘app.secure’ not found.

Original exception:

ImportError: module ‘app’ has no attribute ‘secure’

Process finished with exit code 2

写回答

1回答

7七月

2019-04-25

要听课,要配置配置文件。下的源码都不包含自己的配置的。

0
0

Python Flask高级编程之从0到1开发《鱼书》精品项目

7月老师深入浅出剖析Flask核心机制,和你一起探讨Python高级编程

2751 学习 · 1277 问题

查看课程