Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

flask-restplus is broken by Werkzeug 1.0.0 #777

Open
gil0109 opened this issue Feb 7, 2020 · 43 comments
Open

flask-restplus is broken by Werkzeug 1.0.0 #777

gil0109 opened this issue Feb 7, 2020 · 43 comments
Labels

Comments

@gil0109
Copy link

gil0109 commented Feb 7, 2020

Sorry, I am an Ops guys and not a developer but I hope this helps..

Error Messages/Stack Trace

If applicable, add the stack trace produced by the error

  | Traceback (most recent call last):   | File "./manage.py", line 4, in <module>   | from qsystem import db, application   | File "/opt/app-root/src/qsystem.py", line 16, in <module>   | from flask_restplus import Api   | File "/opt/app-root/lib/python3.6/site-packages/flask_restplus/__init__.py", line 4, in <module>   | from . import fields, reqparse, apidoc, inputs, cors   | File "/opt/app-root/lib/python3.6/site-packages/flask_restplus/fields.py", line 17, in <module>   | from werkzeug import cached_property   | ImportError: cannot import name 'cached_property'

Environment

  • Python version 3.6.
  • flask-marshmallow==0.10.1
  • flask-oidc==1.4.0
  • flask-restplus==0.13.0
@gil0109 gil0109 added the bug label Feb 7, 2020
@R-Sarge
Copy link

R-Sarge commented Feb 7, 2020

I too am experiencing this issue from a fresh install.

$ python app.py 
Traceback (most recent call last):
  File "app.py", line 23, in <module>
    from flask_restplus import Resource, Api
  File "/home/user/programs/python_apps/api-testing/env/lib/python3.6/site-packages/flask_restplus/__init__.py", line 4, in <module>
    from . import fields, reqparse, apidoc, inputs, cors
  File "/home/user/programs/python_apps/api-testing/env/lib/python3.6/site-packages/flask_restplus/fields.py", line 17, in <module>
    from werkzeug import cached_property
ImportError: cannot import name 'cached_property'

Environment:
aniso8601==8.0.0
attrs==19.3.0
Click==7.0
Flask==1.1.1
flask-restplus==0.13.0
importlib-metadata==1.5.0
itsdangerous==1.1.0
Jinja2==2.11.1
jsonschema==3.2.0
MarkupSafe==1.1.1
pkg-resources==0.0.0
pyrsistent==0.15.7
pytz==2019.3
six==1.14.0
Werkzeug==1.0.0
zipp==2.1.0

Edit: Downgrading to Werkzeug to 0.16.0 (temporarily) resolved the issue.

@Dave-Lopper
Copy link

Dave-Lopper commented Feb 7, 2020

Same issue here

Traceback (most recent call last): File "manage.py", line 10, in <module> from application.boot.blueprints import BLUEPRINT as api_bp File "/application/boot/blueprints.py", line 4, in <module> from flask_restplus import Api File "/venv/lib/python3.7/site-packages/flask_restplus/__init__.py", line 4, in <module> from . import fields, reqparse, apidoc, inputs, cors File "/venv/lib/python3.7/site-packages/flask_restplus/fields.py", line 17, in <module> from werkzeug import cached_property ImportError: cannot import name 'cached_property' from 'werkzeug' (/venv/lib/python3.7/site-packages/werkzeug/__init__.py)

psycopg2-binary==2.8.3
mysqlclient==1.4.4
celery==4.3.0
coverage==4.5.4
factory-boy==2.12.0
Flask==1.1.1
Flask-Migrate==2.5.2
flask-restplus==0.13.0
Flask-Script==2.0.6
Flask-Seeder==0.1a2
Flask-SQLAlchemy==2.4.0
flake8==3.7.9
kombu==4.6.3
python-dotenv==0.10.3
pylint==2.4.4
redis==3.3.11
SQLAlchemy-Utils==0.34.2
sentry-sdk[flask]==0.13.1
Flask-Testing==0.7.1
gunicorn==19.9.0
uuid==1.30
nplusone==1.0.0
newrelic==5.2.2.130
scipy==1.3.2
pandas==0.25.3
Faker==2.0.4
Werkzeug==1.0.0

Many thanks in advance

@pransen
Copy link

pransen commented Feb 7, 2020

Temporary workaround: use Werkzeug==0.16.1

@Bonsaikitt3n
Copy link

Temporary workaround: use Werkzeug==0.16.1
Worked for me too.

@gijswobben
Copy link

Found the cause, but not sure how to fix it (if anybody does, please do)...
Flask-restplus has a dependency on Flask:
Flask>=0.8
The latest version of Flask is 1.1.1 and that version of Flask has a dependency on Werkzeug like this:
Werkzeug>=0.15 (https://github.com/pallets/flask/blob/master/setup.py line 56)
Werkzeug release 1.0 yesterday, breaking flask-restplus.

@antespo
Copy link

antespo commented Feb 7, 2020

It's because cached_property has to be explicitly imported from werkzeug.utils now. #738 fixes that but I believe an import in api.py needs to also be fixed.

@rglsk
Copy link

rglsk commented Feb 7, 2020

Fixed here #778 Awaiting for code review.

@fattybenji
Copy link

As #777 (comment) said, you can pin the werkzeug version to 0.16.1 in your project dependencies.

@ziirish
Copy link
Collaborator

ziirish commented Feb 7, 2020

This project should be considered dead as stated in #770
BUT, flask-restx is also impacted by this bug.
I'm working on a hotfix release as of now that will hopefully be available by tomorrow.

@gil0109
Copy link
Author

gil0109 commented Feb 7, 2020

@ziirish thank you. I will ask our dev team to move over. Thank you for taking on this project!

@sreekanth-anubolu
Copy link

sreekanth-anubolu commented Feb 7, 2020

Werkzeug package got new version(1.0.0) update today. The update is not backward compatible, many Flask based libraries are breaking.
A simple fix is that, install Werkzeug==0.16.0, which is working perfectly.
Install this version before installing flask or after it, doesn't really matter, things will work as expected.

@gil0109
Copy link
Author

gil0109 commented Feb 7, 2020

Thanks.. done until packages are updated. I like to keep as new as possible to reduce code rewrites when vulnerabilities are found. I am hoping switching to new library will not require many changes to our code :)

@ziirish
Copy link
Collaborator

ziirish commented Feb 8, 2020

We have now released flask-restx 0.1.1 that workarounds the issue.

HusseinKabbout referenced this issue in qwc-services/qwc-config-service Feb 10, 2020
HusseinKabbout added a commit to qwc-services/qwc-ogc-service that referenced this issue Feb 10, 2020
Downgrade werkzeug and jsonschema, because their newest release break Flask and flask-restplus. More information --> pallets/flask#3486 and noirbizarre/flask-restplus#777
HusseinKabbout added a commit to qwc-services/qwc-data-service that referenced this issue Feb 10, 2020
Downgrade werkzeug and jsonschema, because their newest release break Flask and flask-restplus. More information --> pallets/flask#3486 and noirbizarre/flask-restplus#777
HusseinKabbout added a commit to qwc-services/qwc-map-viewer that referenced this issue Feb 10, 2020
Downgrade werkzeug and jsonschema, because their newest release break Flask and flask-restplus. More information --> pallets/flask#3486 and noirbizarre/flask-restplus#777
HusseinKabbout added a commit to qwc-services/qwc-permalink-service that referenced this issue Feb 10, 2020
Downgrade werkzeug and jsonschema, because their newest release break Flask and flask-restplus. More information --> pallets/flask#3486 and noirbizarre/flask-restplus#777
HusseinKabbout added a commit to qwc-services/qwc-fulltext-search-service that referenced this issue Feb 10, 2020
Downgrade werkzeug and jsonschema, because their newest release break Flask and flask-restplus. More information --> pallets/flask#3486 and noirbizarre/flask-restplus#777
@ghost
Copy link

ghost commented May 13, 2020

Thank you @jblom works perfectly

@ertanuj96
Copy link

got a fix around this issue in api.py just add from werkzeug.utils import cached_property , then your code will work like a charm

@ntung
Copy link

ntung commented Aug 30, 2020

As #777 (comment) said, you can pin the werkzeug version to 0.16.1 in your project dependencies.

This solution works for me. Thanks!

DavidCDreher added a commit to mobius-medical/flask-genshi that referenced this issue Sep 1, 2020
- `cached_property` was deprecated in Werkzeug>0.16.1
- a replacement is available in `werkzeug.utils`

Example issue:
noirbizarre/flask-restplus#777
djpnewton added a commit to zap-me/zapd that referenced this issue Dec 4, 2020
@ketan55patil
Copy link

Temporary workaround: use Werkzeug==0.16.1

This solution worked for me as well.

for me flask-restplus installed Werkzeug [required: >=0.15, installed: 1.0.1]

I downgraded it using pipenv install Werkzeug==0.16.1 as I am using pipenv

zhoujianwen added a commit to zhoujianwen/python-flask-celery-example that referenced this issue Jun 21, 2021
We have now released flask-restx 0.1.1 that workarounds the issue.
@codefather-labs
Copy link

codefather-labs commented Aug 26, 2021

  • works this way!

import werkzeug
from flask.scaffold import _endpoint_from_view_func
from werkzeug.utils import cached_property

import flask

flask.helpers._endpoint_from_view_func = _endpoint_from_view_func

werkzeug.cached_property = cached_property

from flask import Flask
from flask_restplus import Api

@R2calex
Copy link

R2calex commented Sep 29, 2021

"from werkzeug import cached_property" in file api.py file needs to be changed to "from werkzeug.uitls import cached_property"
for current werkzeug versions. It's already fixed in fields.py could you commit this change as well please?

regards,

@sreerajkksd
Copy link

Is someone going to fix this small bug ? Downgrading werkzeug <= 1.0.0 is not a long term solution for this problem

@ReyB59
Copy link

ReyB59 commented Dec 8, 2021

Is someone going to fix this small bug ? Downgrading werkzeug <= 1.0.0 is not a long term solution for this problem

Yes agree !

@j5awry
Copy link
Collaborator

j5awry commented Dec 8, 2021

No, this bug won't get fixed. Flask-restplus has ceased development. There are no active maintainers. There is a fork, though we are far behind as well (but this issue has been fixed in flask-restx at least)

#770

@vbudonyi
Copy link

vbudonyi commented Apr 4, 2022

As I see werkzeug has been updated recently(2.1+) and a workaround slightly changed because they remove BaseResponse and combine it with Response

import werkzeug
from flask.scaffold import _endpoint_from_view_func
from werkzeug.utils import cached_property
from werkzeug.wrappers import Response
import flask

flask.helpers._endpoint_from_view_func = _endpoint_from_view_func

werkzeug.cached_property = cached_property
werkzeug.wrappers.BaseResponse = Response

from flask import Flask
from flask_restplus import Api

@Sumanshu-Nankana
Copy link

if we downgrade werkzeug 0.16.1 , looks we need to downgrade flask as well.

flask 2.1.1 requires Werkzeug>=2.0, but you have werkzeug 0.16.1 which is incompatible

@NemoAng
Copy link

NemoAng commented Jun 3, 2022

it's already two more years, Werkzeug is 2.1.2. still nobody fix the issue?

ERROR: flask 2.1.2 has requirement Werkzeug>=2.0, but you'll have werkzeug 0.16.1 which is incompatible.
ERROR: flask-login 0.6.1 has requirement Werkzeug>=1.0.1, but you'll have werkzeug 0.16.1 which is incompatible.

@joshuaroot
Copy link

@NemoAng

Move to flask_restx, restplus will no longer be updated

@13678380508
Copy link

Ask when this bug will be fixed?

IncredibleMaster added a commit to IncredibleMaster/data_service_py that referenced this issue Jan 30, 2023
Downgrade werkzeug and jsonschema, because their newest release break Flask and flask-restplus. More information --> pallets/flask#3486 and noirbizarre/flask-restplus#777
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.