axnsan12 / drf-yasg

Automated generation of real Swagger/OpenAPI 2.0 schemas from Django REST Framework code.
https://drf-yasg.readthedocs.io/en/stable/
Other
3.42k stars 439 forks source link

ModuleNotFoundError: No module named 'jsonschema.compat' #744

Open spavlovich001 opened 3 years ago

spavlovich001 commented 3 years ago

drf_yasg==1.20.0 swagger_spec_validator==2.7.3

Internal Server Error: /
Traceback (most recent call last):
  File "/usr/local/lib/python3.9/site-packages/django/core/handlers/exception.py", line 47, in inner
    response = get_response(request)
  File "/usr/local/lib/python3.9/site-packages/django/core/handlers/base.py", line 204, in _get_response
    response = response.render()
  File "/usr/local/lib/python3.9/site-packages/django/template/response.py", line 105, in render
    self.content = self.rendered_content
  File "/usr/local/lib/python3.9/site-packages/rest_framework/response.py", line 70, in rendered_content
    ret = renderer.render(self.data, accepted_media_type, context)
  File "/usr/local/lib/python3.9/site-packages/drf_yasg/renderers.py", line 35, in render
    return codec.encode(data)
  File "/usr/local/lib/python3.9/site-packages/drf_yasg/codecs.py", line 73, in encode
    VALIDATORS[validator](copy.deepcopy(spec))
  File "/usr/local/lib/python3.9/site-packages/drf_yasg/codecs.py", line 29, in _validate_swagger_spec_validator
    from swagger_spec_validator.common import SwaggerValidationError as SSVErr
  File "/usr/local/lib/python3.9/site-packages/swagger_spec_validator/__init__.py", line 8, in <module>
    from swagger_spec_validator.util import validate_spec_url
  File "/usr/local/lib/python3.9/site-packages/swagger_spec_validator/util.py", line 9, in <module>
    from swagger_spec_validator import validator12
  File "/usr/local/lib/python3.9/site-packages/swagger_spec_validator/validator12.py", line 29, in <module>
    from swagger_spec_validator.ref_validators import default_handlers
  File "/usr/local/lib/python3.9/site-packages/swagger_spec_validator/ref_validators.py", line 14, in <module>
    from jsonschema.compat import iteritems
ModuleNotFoundError: No module named 'jsonschema.compat'
AFusco commented 3 years ago

Run into the same error today. Everything was fine a week ago. Apparently jsonschema package updated to version 4.0.0 and the compat module doesn't exist anymore.

While we wait for a dependency upgrade from swagger_spec_validator, I solved it by running pip install -U 'jsonschema<4.0'