python-如何修复烧瓶蓝图错误-未找到模块

2021-01-03 15点热度 0人点赞 0条评论

我看过帮助指南等等,但我仍然不能让烧瓶的设计图起作用。

这是我的结构

root /
config.py
   |app/
        | __init__.py
        | user_auth/

              | __init__.py
              | app.py
              | routes.py

在应用程序中/初始化
.py文件,如下所示
from flask import Flask
from config import Config


app = Flask(__name__)
app.config.from_object(Config)

from .user_auth.routes import user_auth


app.register_blueprint(user_auth, url_prefix="")
来自用户\u auth初始化
.py文件是
from flask import Flask
from config import Config
from flask_sqlalchemy import SQLAlchemy
from flask_migrate import Migrate
from flask_login import LoginManager

app = Flask(__name__)
app.config.from_object(Config)
db = SQLAlchemy(app)
migrate = Migrate(app, db)
login = LoginManager(app)
login.login_view = 'login'

app.config['SECRET_KEY'] = 'trial'

from user_auth import routes, models

这是用户_auth/routes.py文件

from user_auth import app, db
from flask_login import login_required
from user_auth.forms import RegistrationForm, LoginForm
from flask import request, render_template, flash, redirect, url_for, Blueprint
from werkzeug.urls import url_parse
from flask_login import logout_user

from flask_login import current_user, login_user
from user_auth.models import User


from flask import Blueprint
user_auth = Blueprint('user_auth', __name__)

@app.route('/')
@app.route('/index')
def index():
    return render_template('index.html', title='Welcome')


@app.route('/register', methods=["POST", "GET"])
def register():

... (Other paths)

我正在运行Windows并使用以下命令

set FLASK_APP=app

然后我用

flask run

当我试图跑步时,它会说:

Error: While importing "app", an ImportError was raised:

Traceback (most recent call last):
  File "...\python38-32\lib\site-packages\flask\cli.py", line 240, in locate_app
    __import__(module_name)
  File "...\root\app\__init__.py", line 8, in <module>
    from .user_auth.routes import user_auth
  File "...\root\app\user_auth\__init__.py", line 16, in <module>
    from user_auth import routes, models
ModuleNotFoundError: No module named 'user_auth'

提前感谢你的帮助。

查看隐藏内容需要支付:¥1
查看

未经允许不得转载!python-如何修复烧瓶蓝图错误-未找到模块

本文地址:https://ans.52learn.online/1888

ANS52LEARN

DO BEST