我试过这个;
from flask import Flask, render_template, redirect, url_for
from flask_bootstrap import Bootstrap5
from flask_sqlalchemy import SQLAlchemy
from flask_wtf import FlaskForm
from wtforms import StringField, SubmitField
from wtforms.validators import DataRequired, URL
from flask_ckeditor import CKEditor, CKEditorField
然后我遇到了这个 输出;
Traceback (most recent call last):
File "/home/mustafa/Desktop/Backend/REST-API/some_project/main.py", line 7, in <module>
from flask_ckeditor import CKEditor, CKEditorField
File "/home/mustafa/Desktop/Backend/REST-API/some_project/venv/lib/python3.10/site- packages/flask_ckeditor/__init__.py", line 12, in <module>
from flask import current_app, Markup, Blueprint, url_for, request, jsonify, render_template_string
ImportError: cannot import name 'Markup' from 'flask' (/home/mustafa/Desktop/Backend/REST- API/some_project/venv/lib/python3.10/site-packages/flask/__init__.py)
需求.txt;
Bootstrap_Flask==2.3.0
Flask==3.0.0
Flask_CKEditor==0.4.6
flask_sqlalchemy==3.1.1
Flask_WTF==1.2.1
WTForms==3.0.1
我看过与我的问题标题相似的相同问题标签,但我没有找到适合我的案例的任何解决方案。请帮忙。
由于 Flask 使用 Jinja2 已经有一段时间了,他们在 3.0.0 版本中删除了标记的重新导出,请参阅 GitHub。
我建议您使用 Flask 的 2.2.x 版本(仍支持此导入),或者不要使用 Flask_ckeditor。