cannot import name ‘import_string‘ from ‘werkzeug‘【bug解决】

BUG

ImportError: cannot import name ‘import_string’ from ‘werkzeug’ (/home/cc/Desktop/test/alg/envi/lib/python3.8/site-packages/werkzeug/init.py)

cannot import name ‘import_string’ from ‘werkzeug’
在这里插入图片描述
出现这种情况是因为版本不兼容的问题。

from werkzeug.utils import import_string
import werkzeug
werkzeug.import_string = import_string

import flask_cache

解决

在这里插入图片描述

更改Werkzeug的版本为0.16.1
Werkzeug==0.16.1
解决问题

原因

新版本和旧版本规则不一样:
如下:

from werkzeug import import_string
from werkzeug.utils import import_string

更改统一即可解决。

猜你喜欢

转载自blog.csdn.net/weixin_52908342/article/details/125870218