manager.py中的from application import app,manager导入不了
来源:4-9 打造高可用flask mvc框架
幕布斯828814
2018-11-04
from flask import Flask
from flask_script import Manager
from flask_sqlalchemy import SQLAlchemy
import os
class Application(Flask):
def __init__(self,import_name):
super(Application,self).__init__(import_name)
self.config.from_pyfile('config/base_setting.py')
if"ops.config" in os.environ:
self.config.from_pyfile('config/%s_setting.py'%os.environ['ops_config'])
db.init_app(self)
db = SQLAlchemy()
app = Application(__name__)
manager =Manager(app)
5回答
-
慕前端0512051
2019-04-25
同学,我也是这个错误,你是怎么解决的啊,奇奇怪怪的
00 -
编程浪子
2018-11-09
FileNotFoundError: [Errno 2] Unable to load configuration file (No such file or directory): 'E:\\pycharm文件\\order\\web\\config/base_setting.py'
这个报错是说没有文件了,这个文件有没有了,还有位置也不对,config 和web 一个同级目录的,不在web下面。建议和源码对比下看看代码结构
00 -
幕布斯828814
提问者
2018-11-07
File "manager.py", line 2, in <module>
from application import app,manager
File "E:\pycharm文件\order\web\application.py", line 15, in <module>
app = Application(__name__)
File "E:\pycharm文件\order\web\application.py", line 8, in __init__
self.config.from_pyfile('config/base_setting.py')
File "E:\python3.7\lib\site-packages\flask\config.py", line 129, in from_pyfile
with open(filename, mode='rb') as config_file:
FileNotFoundError: [Errno 2] Unable to load configuration file (No such file or directory): 'E:\\pycharm文件\\order\\web\\config/base_setting.py'
00 -
幕布斯828814
提问者
2018-11-07
from application import app,manager
from flask_script import Server
import www
manager.add_command("runserver",Server(host='0.0.0.0',port=app.config['SERVER_PORT'],use_debugger=True,use_reloader=True))
def main():
manager.run()
if __name__=='__main__':
try:
import sys
sys.exit(main())
except Exception as e:
import traceback
traceback.print_exc()00 -
编程浪子
2018-11-06
哪个文件报错这个,建议把完整的报错信息发出来
022022-08-08
相似问题