When I run flask-server, I get bellow ImportError.
Traceback (most recent call last):
File "/usr/lib/python3.6/runpy.py", line 193, in _run_module_as_main
"__main__", mod_spec)
File "/usr/lib/python3.6/runpy.py", line 85, in _run_code
exec(code, run_globals)
File "python-flask-server/swagger_server/__main__.py", line 3, in <module>
import connexion
File "python-flask-server/venv/lib/python3.6/site-packages/connexion/__init__.py", line 3, in <module>
from .apis import AbstractAPI # NOQA
File "python-flask-server/venv/lib/python3.6/site-packages/connexion/apis/__init__.py", line 1, in <module>
from .abstract import AbstractAPI # NOQA
File "python-flask-server/venv/lib/python3.6/site-packages/connexion/apis/abstract.py", line 14, in <module>
from ..operation import Operation
File "python-flask-server/venv/lib/python3.6/site-packages/connexion/operation.py", line 7, in <module>
from .decorators import validation
File "python-flask-server/venv/lib/python3.6/site-packages/connexion/decorators/validation.py", line 9, in <module>
from werkzeug import FileStorage
ImportError: cannot import name 'FileStorage'
2.4.13
https://petstore.swagger.io/v2/swagger.json
I generated flask server from swagger-editor.
I use venv and run swagger_server
python -m venv venv
source venv/bin/activate
pip3 install -r requirements.txt
python3 -m swagger_server
https://github.com/zalando/connexion/issues/1149
I can fix this bug when adding two line in reqirements.txt.
connexion == 1.1.15
python_dateutil == 2.6.0
setuptools >= 21.0.0
+ Werkzeug == 0.12.2
+ flask == 0.10.1
I fixed this same issue by updating connexion to 2.x.x. The master branch already generates a requirements.txt file with an updated connexion version
I had this same issue with the latest clone.
I have the same FileStorage error using:
connexion==2.3.0
Flask==1.1.2
Werkzeug==1.0.1
During handling of the above exception, another exception occurred:
../../../venv/py37/lib/python3.7/site-packages/py/_path/local.py:704: in pyimport
__import__(modname)
../../../venv/py37/lib/python3.7/site-packages/_pytest/assertion/rewrite.py:152: in exec_module
exec(co, module.__dict__)
source_code/tests/conftest.py:6: in <module>
from test_api.run import create_app
source_code/test_api/run.py:3: in <module>
import connexion
../../../venv/py37/lib/python3.7/site-packages/connexion/__init__.py:5: in <module>
from .apis import AbstractAPI # NOQA
../../../venv/py37/lib/python3.7/site-packages/connexion/apis/__init__.py:1: in <module>
from .abstract import AbstractAPI # NOQA
../../../venv/py37/lib/python3.7/site-packages/connexion/apis/abstract.py:10: in <module>
from ..operations import make_operation
../../../venv/py37/lib/python3.7/site-packages/connexion/operations/__init__.py:1: in <module>
from .abstract import AbstractOperation # noqa
../../../venv/py37/lib/python3.7/site-packages/connexion/operations/abstract.py:10: in <module>
from ..decorators.response import ResponseValidator
../../../venv/py37/lib/python3.7/site-packages/connexion/decorators/response.py:12: in <module>
from .validation import ResponseBodyValidator
../../../venv/py37/lib/python3.7/site-packages/connexion/decorators/validation.py:9: in <module>
from werkzeug import FileStorage
E ImportError: cannot import name 'FileStorage' from 'werkzeug'
Problem fixed doing:
pip uninstall Werkzeug connexion
pip install connexion==2.6.0
If you also want working tox tests, apply this patch:
diff --git i/requirements.txt w/requirements.txt
index b5bc506..c44cfa7 100644
--- i/requirements.txt
+++ w/requirements.txt
@@ -1,3 +1,3 @@
-connexion == 2.2.0
+connexion == 2.7.0
python_dateutil == 2.6.0
setuptools >= 21.0.0
diff --git i/test-requirements.txt w/test-requirements.txt
index 7f8d96e..3bff640 100644
--- i/test-requirements.txt
+++ w/test-requirements.txt
@@ -1,4 +1,4 @@
-flask_testing==0.6.1
+flask_testing
coverage>=4.0.3
nose>=1.3.7
pluggy>=0.3.1
Still has the requirements.txt set to connexion == 2.2.0
I believe you must be using the 2.X branch.
Most helpful comment
I fixed this same issue by updating connexion to 2.x.x. The master branch already generates a requirements.txt file with an updated connexion version