加入收藏 | 设为首页 | 会员中心 | 我要投稿 北几岛 (https://www.beijidao.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 大数据 > 正文

Python3 flask 依赖包 werkzeug 报错 ImportError

发布时间:2021-05-21 04:52:53 所属栏目:大数据 来源: https://blog.csdn.net/yilovex
导读:pip 是 Python 中超级好用的包管理工具,但是 pip 会不定时更新 WARNING: You are using pip version 19.3.1; however,version 20.0.2 is available.You should consider upgrading via the 'pip install --upgrade pip' command. 提示已经很明显了,我们使

pipPython 中超级好用的包管理工具,但是 pip 会不定时更新

WARNING: You are using pip version 19.3.1; however,version 20.0.2 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.

提示已经很明显了,我们使用 upgrade 更新我们的 pip

pip install --upgrade pip

但是更新完以后就郁闷了,之前的项目启动不起来了。。。

Traceback (most recent call last):
  File "/Users/zhangyi/Documents/crm/manage.py",line 7,in <module>
    from app.urls import blueprint
  File "/Users/zhangyi/Documents/crm/app/urls.py",line 5,in <module>
    from flask_restplus import Api
  File "/Users/zhangyi/.virtualenvs/crm_user_service/lib/python3.8/site-packages/flask_restplus/__init__.py",line 4,in <module>
    from . import fields,reqparse,apidoc,inputs,cors
  File "/Users/zhangyi/.virtualenvs/crm_user_service/lib/python3.8/site-packages/flask_restplus/fields.py",line 17,in <module>
    from werkzeug import cached_property
ImportError: cannot import name 'cached_property' from 'werkzeug' (/Users/zhangyi/.virtualenvs/crm_user_service/lib/python3.8/site-packages/werkzeug/__init__.py)

根据报错,我们知道是因为导入 werkzeug 包时报错。。。

作为一个“面向谷歌编程”的程序员,查询后得知这是因为 werkzeug 新版本里需要显式导入该模块

所以我没找到它的包路径

/Users/zhangyi/.virtualenvs/crm_user_service/lib/python3.8/site-packages/werkzeug/__init__.py

添加一行

from werkzeug.utils import cached_property

即可

(编辑:北几岛)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读