简体   繁体   English

AttributeError:模块“flask.views”没有属性“MethodViewType”

[英]AttributeError: module 'flask.views' has no attribute 'MethodViewType'

Since two days ago I receive this the moment I try to import flask_apispec.extension:从两天前开始,我在尝试导入 flask_apispec.extension 的那一刻就收到了这个消息:

>>> import flask_apispec.extension
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Users\MyUser\AppData\Local\pypoetry\Cache\virtualenvs\gfp-LphObOQn-py3.9\lib\site-packages\flask_apispec\__init__.py", line 1, in <module>        
    from flask_apispec.views import ResourceMeta, MethodResource
  File "C:\Users\MyUser\AppData\Local\pypoetry\Cache\virtualenvs\gfp-LphObOQn-py3.9\lib\site-packages\flask_apispec\views.py", line 41, in <module>
    class MethodResourceMeta(ResourceMeta, flask.views.MethodViewType):
AttributeError: module 'flask.views' has no attribute 'MethodViewType'

I'm attempting to import it after apispec and marshmallow (libraries were installed using poetry):我试图在 apispec 和 marshmallow 之后导入它(库是使用诗歌安装的):

from apispec import APISpec
from apispec.ext.marshmallow import MarshmallowPlugin
import flask_apispec.extension

I have the following versions:我有以下版本:

apispec = "^5.2.2"
Flask = "2.1.1"
flask_apispec = "0.11.1"

Different versions didn't help, resetting the environment didn't help either...不同的版本没有帮助,重置环境也没有帮助......

Flask has removed MethodViewType from flask.views and flask-apispec still uses it. Flask 已从MethodViewType中删除 MethodViewType, flask-apispec仍在使用它。

There is a PR for flask-apispec that may fix it, but as writing this answer, it is not merged into the main branch. flask-apispec有一个 PR 可以修复它,但是在写这个答案时,它没有合并到主分支中。 You may try it by running您可以通过运行来尝试

pip install git+https://github.com/jmcarp/flask-apispec.git@refs/pull/238/merge

More info on MethodViewType removal有关MethodViewType删除的更多信息

More info on the fix有关修复的更多信息

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 AttributeError:“模块”对象没有属性“视图” - AttributeError: 'module' object has no attribute 'views' Flask-AttributeError:“模块”对象没有属性“ items” - Flask - AttributeError: 'module' object has no attribute 'items' Flask AttributeError:模块“app”没有属性“run” - Flask AttributeError: module 'app' has no attribute 'run' AttributeError: 模块“flask”没有属性“route” - AttributeError: module 'flask' has no attribute 'route' Flask(flask db init):AttributeError:模块“时间”没有属性“时钟” - Flask(flask db init): AttributeError: module 'time' has no attribute 'clock' AttributeError: 模块 Django.contrib.auth.views 没有属性 - AttributeError: module Django.contrib.auth.views has no attribute AttributeError:模块“PrivateSchools.views”没有属性“HomePage” - AttributeError: module 'PrivateSchools.views' has no attribute 'HomePage' AttributeError:模块“courses.views”没有属性“搜索” - AttributeError: module 'courses.views' has no attribute 'search' Djnago: AttributeError: 模块 'django.views.generic' 没有属性 'Detail' - Djnago : AttributeError: module 'django.views.generic' has no attribute 'Detail' PySpark + Flask + CherryPy-AttributeError:“模块”对象没有属性“树” - PySpark+Flask+CherryPy - AttributeError: 'module' object has no attribute 'tree'
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM