-
Notifications
You must be signed in to change notification settings - Fork 331
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 2.0.0 - ImportError: cannot import name '_endpoint_from_view_func' from 'flask.helpers' #308
Comments
yes broke my pipeline |
Changed in: pallets/flask@b146a13 Fixes: python-restx#308 Signed-off-by: Jürgen Löhel <[email protected]>
Thanks for catching this quickly. I've told Github to run the tests. on the PR. I don't foresee any issues there. I'll get this merged into main, and then cut a release ASAP. |
flask-restful ran into same problem and fixed that issue: flask-restful/flask-restful#914 |
Hello. Thank you for this fix. I did something similar in my venv. Are you going to publish the fix soonish on pypi ? |
Seems it is published on pypi, nice @j5awry . But there is a dependency issue with Flask 2.0, probably due to this: $ poetry install
Creating virtualenv statsservice-eyi4DPj7-py3.9 in /home/cedric/.cache/pypoetry/virtualenvs
Updating dependencies
Resolving dependencies... (3.9s)
SolverProblemError
Because flask-restx (0.4.0) depends on Flask (>=0.8,<2.0.0)
and no versions of flask-restx match >0.4.0,<0.5.0, flask_restx (>=0.4.0,<0.5.0) requires Flask (>=0.8,<2.0.0).
So, because statsservice depends on both Flask (^2.0.0) and flask_restx (^0.4.0), version solving failed.
at ~/.poetry/lib/poetry/puzzle/solver.py:241 in _solve
237│ packages = result.packages
238│ except OverrideNeeded as e:
239│ return self.solve_in_compatibility_mode(e.overrides, use_latest=use_latest)
240│ except SolveFailure as e:
→ 241│ raise SolverProblemError(e)
242│
243│ results = dict(
244│ depth_first_search(
245│ PackageNode(self._package, packages), aggregate_package_nodes |
@cedricbonhomme I think sometimes this happens if you are using the same venv. Try to clear all packages from this venv and rerun pip again |
I deleted it, even cleaned the cache of poetry. Actually in the archive here it is written ''Flask>=0.8, <2.0.0''. So it seems poetry is right. |
check your |
In the pyproject.toml I have these lines: Flask = "^2.0.0"
flask_restx = "^0.4.0"
...
... To be sure I have deleted the lock file (poetry.lock). As well deleted the virtual env and cleaned the cache of poetry. I am not using a config.toml file. What I do not understand it's this: On a new project: cedric@numero5:~$ mkdir newproject
cedric@numero5:~$ cd newproject/
cedric@numero5:~/newproject$ poetry init
This command will guide you through creating your pyproject.toml config.
Package name [newproject]:
Version [0.1.0]:
Description []:
Author [Cédric Bonhomme <[email protected]>, n to skip]:
License []:
Compatible Python versions [^3.9]:
Would you like to define your main dependencies interactively? (yes/no) [yes]
You can specify a package in the following forms:
- A single name (requests)
- A name and a constraint (requests@^2.23.0)
- A git url (git+https://github.com/python-poetry/poetry.git)
- A git url with a revision (git+https://github.com/python-poetry/poetry.git#develop)
- A file path (../my-package/my-package.whl)
- A directory (../my-package/)
- A url (https://example.com/packages/my-package-0.1.0.tar.gz)
Search for package to add (or leave blank to continue):
Would you like to define your development dependencies interactively? (yes/no) [yes]
Search for package to add (or leave blank to continue):
Generated file
[tool.poetry]
name = "newproject"
version = "0.1.0"
description = ""
authors = ["Cédric Bonhomme <[email protected]>"]
[tool.poetry.dependencies]
python = "^3.9"
[tool.poetry.dev-dependencies]
[build-system]
requires = ["poetry-core>=1.0.0"]
build-backend = "poetry.core.masonry.api"
Do you confirm generation? (yes/no) [yes]
cedric@numero5:~/newproject$
cedric@numero5:~/newproject$
cedric@numero5:~/newproject$
cedric@numero5:~/newproject$ ls -lh
total 4,0K
-rw-rw-r-- 1 cedric cedric 296 mai 12 17:10 pyproject.toml
cedric@numero5:~/newproject$
cedric@numero5:~/newproject$
cedric@numero5:~/newproject$ poetry install
Creating virtualenv newproject-Ur5O_nme-py3.9 in /home/cedric/.cache/pypoetry/virtualenvs
Updating dependencies
Resolving dependencies... (0.1s)
Writing lock file
cedric@numero5:~/newproject$ poetry add Flask
Using version ^2.0.0 for Flask
Updating dependencies
Resolving dependencies... (7.0s)
Writing lock file
Package operations: 6 installs, 0 updates, 0 removals
• Installing markupsafe (2.0.0)
• Installing click (8.0.0)
• Installing itsdangerous (2.0.0)
• Installing jinja2 (3.0.0)
• Installing werkzeug (2.0.0)
• Installing flask (2.0.0)
cedric@numero5:~/newproject$ poetry add flask_restx
Using version ^0.4.0 for flask-restx
Updating dependencies
Resolving dependencies... (0.1s)
SolverProblemError
Because no versions of flask-restx match >0.4.0,<0.5.0
and flask-restx (0.4.0) depends on Flask (>=0.8,<2.0.0), flask-restx (>=0.4.0,<0.5.0) requires Flask (>=0.8,<2.0.0).
So, because newproject depends on both Flask (^2.0.0) and flask-restx (^0.4.0), version solving failed.
at ~/.poetry/lib/poetry/puzzle/solver.py:241 in _solve
237│ packages = result.packages
238│ except OverrideNeeded as e:
239│ return self.solve_in_compatibility_mode(e.overrides, use_latest=use_latest)
240│ except SolveFailure as e:
→ 241│ raise SolverProblemError(e)
242│
243│ results = dict(
244│ depth_first_search(
245│ PackageNode(self._package, packages), aggregate_package_nodes |
I have the same problem as @cedricbonhomme. But directly with pip :) |
Yes, there are more steps to go. This isn't the only issue. For now it's better to use Flask 1.1.2 together with flask-restx. I am not so familiar with poetry but I think it should be:
which is equal with:
|
exactly, that's the point (as you say). But this release (v 0.4.0) of Flask-restx is supposed to work with Flask 2.0. |
@cedricbonhomme No, it does not work with Flask 2.0.0. Hence the pin. There are other issues around Werkzeug and Flask that our CI pipeline tests found. We have pinned to < 2.0.0 for Flask and werkzeug until upstream bugs are addressed, and we can fix all calls in our code. we fixed a single bug someone found, but the pipeline found more, some of which are upstream |
OK, thanks. Now I understand. My project actually works with Flask 2 and flask-restx 0.4.0 (i changed the lib in the venv manually). I will see if I can contribute to fix the errors I might have. |
@cedricbonhomme You can install flask-restx also with |
it's entirely possible that specific projects will work with Flask and werkzeug 2.0.0. Our tests are failing due to some specific tests. here's an example of a failure: https://github.com/python-restx/flask-restx/runs/2565726592 at least one is related to something report upstream to werkzeug: pallets/werkzeug#2115 we'll need to dig through a bit to see all possible interactions. I'll open a separate issue specifically to track upgrading flask and werkzeug to 2.0.0 |
#313 opened to track unpinning and fixing any other issues we find with upgrading flask and werkzeug |
Since Poetry has better support for dependency management than using a simple pip requirements file, Poetry is now used to fetch dependencies. Also the versions are now more stricly given, since sometimes the most up-to-date versions are not compatible with other up-to-date versions. This happens with the new flask version 2.0.0, which came out this week and break the build, since flask-restx is not working correctly with flask 2.0.0 See python-restx/flask-restx#308
The helper function is not longer available in Flask 2.0.0
flask-restful/flask-restful#913
The text was updated successfully, but these errors were encountered: