You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[Optional] Sponsorship to speed up the bug fix or feature request (example)
Description
Generating server code with python-flask and launching the program leads to ImportError exception: ImportError: cannot import name 'json' from 'itsdangerous' (/usr/local/lib/python3.10/site-packages/itsdangerous/__init__.py). This is probably caused by the following:
Traceback (most recent call last):
File "/usr/local/lib/python3.10/runpy.py", line 196, in _run_module_as_main
return _run_code(code, main_globals, None,
File "/usr/local/lib/python3.10/runpy.py", line 86, in _run_code
exec(code, run_globals)
File "/usr/src/app/test_rest_api/__main__.py", line 5, in <module>
from test_rest_api import encoder
File "/usr/src/app/test_rest_api/encoder.py", line 1, in <module>
from connexion.apps.flask_app import FlaskJSONEncoder
File "/usr/local/lib/python3.10/site-packages/connexion/apps/flask_app.py", line 11, in <module>
import flask
File "/usr/local/lib/python3.10/site-packages/flask/__init__.py", line 19, in <module>
from . import json
File "/usr/local/lib/python3.10/site-packages/flask/json/__init__.py", line 15, in <module>
from itsdangerous import json as _json
ImportError: cannot import name 'json' from 'itsdangerous' (/usr/local/lib/python3.10/site-packages/itsdangerous/__init__.py)
openapi-generator version
Latest Docker image
openapi-generator-cli 6.0.0-SNAPSHOT
commit : 6f37409
built : 2022-03-10T08:57:57Z
OpenAPI declaration file content or url
Reproduced with any specification file. It does not depend on OpenAPI definitions.
It can be fixed by changing the Flask version and setting a specific MarkupSafe version as suggested in the relevant issues of above. So manually editing the requirements.txt file from this:
connexion[swagger-ui] >= 2.6.0; python_version>="3.6"
# 2.3 is the last version that supports python 3.4-3.5
connexion[swagger-ui] <= 2.3.0; python_version=="3.5" or python_version=="3.4"
# connexion requires werkzeug but connexion < 2.4.0 does not install werkzeug
# we must peg werkzeug versions below to fix connexion
# https://github.com/zalando/connexion/pull/1044
werkzeug == 0.16.1; python_version=="3.5" or python_version=="3.4"
swagger-ui-bundle >= 0.0.2
python_dateutil >= 2.6.0
setuptools >= 21.0.0
Flask == 1.1.2
to this
connexion[swagger-ui] >= 2.6.0; python_version>="3.6"
# 2.3 is the last version that supports python 3.4-3.5
connexion[swagger-ui] <= 2.3.0; python_version=="3.5" or python_version=="3.4"
# connexion requires werkzeug but connexion < 2.4.0 does not install werkzeug
# we must peg werkzeug versions below to fix connexion
# https://github.com/zalando/connexion/pull/1044
werkzeug == 0.16.1; python_version=="3.5" or python_version=="3.4"
swagger-ui-bundle >= 0.0.2
python_dateutil >= 2.6.0
setuptools >= 21.0.0
Flask == 1.1.4
MarkupSafe == 2.0.1
Fixes the issue.
The text was updated successfully, but these errors were encountered:
Bug Report Checklist
Description
Generating server code with
python-flask
and launching the program leads to ImportError exception:ImportError: cannot import name 'json' from 'itsdangerous' (/usr/local/lib/python3.10/site-packages/itsdangerous/__init__.py)
. This is probably caused by the following:pallets/flask#4455
pallets/markupsafe#284
Full stack trace:
openapi-generator version
Latest Docker image
OpenAPI declaration file content or url
Reproduced with any specification file. It does not depend on OpenAPI definitions.
Generation Details
Steps to reproduce
Related issues/PRs
None.
Suggest a fix
It can be fixed by changing the
Flask
version and setting a specificMarkupSafe
version as suggested in the relevant issues of above. So manually editing the requirements.txt file from this:to this
Fixes the issue.
The text was updated successfully, but these errors were encountered: