Traceback (most recent call last):

總是幸福的老豌豆發表於2020-11-21

前言

最近開發python flask框架時,執行入口檔案報如下錯誤


報錯資訊:

C:\Users\Administrator\.virtualenvs\movie_project-7781sJXo\Scripts\python.exe D:/code/movie_project/manage.py
Traceback (most recent call last):
  File "D:\code\movie_project\manage.py", line 10, in <module>
    from app import app
  File "D:\code\movie_project\app\__init__.py", line 19, in <module>
    app.register_blueprint(admin_blueprint, url_prefix="/admin")
  File "C:\Users\Administrator\.virtualenvs\movie_project-7781sJXo\lib\site-packages\flask\app.py", line 98, in wrapper_func
    return f(self, *args, **kwargs)
  File "C:\Users\Administrator\.virtualenvs\movie_project-7781sJXo\lib\site-packages\flask\app.py", line 1157, in register_blueprint
    assert self.blueprints[blueprint.name] is blueprint, (
AssertionError: A name collision occurred between blueprints <flask.blueprints.Blueprint object at 0x000002B8830B3730> and <flask.blueprints.Blueprint object at 0x000002B8830B3580>. Both share the same name "home". Blueprints that are created on the fly need unique names.

Process finished with exit code 1


解決:

通過 debug除錯,感覺是我們的模組註冊藍圖時報錯,
在這裡插入圖片描述

原因

在admin 初始化檔案裡面,我寫錯了名稱,需要把下面標紅的“home” 改為"admin"
在這裡插入圖片描述

重新啟動:

在這裡插入圖片描述

相關文章