When the application starts library throws ImportError
File "/home/anatoliy/Projects/Python/skippplatform/skipro/skipro/urls/dev.py", line 8, in <module>
from drf_yasg.generators import OpenAPISchemaGenerator
File "/home/anatoliy/.local/share/virtualenvs/skipro-hLwcq6KW/lib/python3.6/site-packages/drf_yasg/generators.py", line 11, in <module>
from rest_framework.schemas.generators import SchemaGenerator, endpoint_ordering, get_pk_name
ImportError: cannot import name 'SchemaGenerator'
This happens because in new version SchemaGenerator was renamed to BaseSchemaGenerator.
I can confirm that is an issue. Our builds stopped working this morning, and it starts working with drf==3.9.6, but fails with drf==3.10.0
authentication_classes=(authentication.BasicAuthentication,),
File "/usr/local/lib/python3.6/dist-packages/drf_yasg/views.py", line 68, in get_schema_view
_generator_class = generator_class or swagger_settings.DEFAULT_GENERATOR_CLASS
File "/usr/local/lib/python3.6/dist-packages/drf_yasg/app_settings.py", line 121, in __getattr__
val = perform_import(val, attr)
File "/usr/local/lib/python3.6/dist-packages/rest_framework/settings.py", line 166, in perform_import
return import_from_string(val, setting_name)
File "/usr/local/lib/python3.6/dist-packages/rest_framework/settings.py", line 180, in import_from_string
raise ImportError(msg)
ImportError: Could not import 'drf_yasg.generators.OpenAPISchemaGenerator' for API setting 'DEFAULT_GENERATOR_CLASS'. ImportError: cannot import name 'SchemaGenerator'.
Breaking for me even for 3.9.4. Installing packaging fixed it for me.
pip3 install packaging
Still reproduced. ImportError: Could not import 'drf_yasg.generators.OpenAPISchemaGenerator' for API setting 'DEFAULT_GENERATOR_CLASS'. ImportError: cannot import name 'SchemaGenerator'.
DRF: 3.10.4 and 3.9.4
Python 3.6
pip3 install packaging - solve problem
Breaking for me even for 3.9.4. Installing packaging fixed it for me.
Known regression: #412
tengo el mismo problema路
'drf_yasg.generators.OpenAPISchemaGenerator' for API setting 'DEFAULT_GENERATOR_CLASS'
SWAGGER_SETTINGS = {
"DEFAULT_AUTO_SCHEMA_CLASS": "apps.api.inspectors.SwaggerAutoSchema"
}
pip install packaging solved for the problem also
pip install packagingsolved for the problem also
Same issue happens to me. But I failed to solve this problem by "pip3 install packaging". Any idea?
@rainbow2177 Installing the latest version (1.17.0) should solve this issue.
confirm, fixed in the last release.
1.10.3
I use the version: djangorestframework==3.10.3 drf-yasg==1.16.0
It doesn't work.
@rainbow2177 the last version is ==1.17.0
Same problem on djangorestframework==3.12.1 and drf-yasg==1.17.1.
Solving by downgrade drf prior to 3.12.
@shagohead Please see the newly created fork drf-yasg2 https://github.com/axnsan12/drf-yasg/issues/641#issuecomment-704327697
It's on PyPI now, and we are working on getting a few remaining issues solved. It is compatible with DRF 3.12.
I solved the problem using these versions drf-yasg==1.17.1 and djangorestframework==3.11.0
Yes, an alternative is to pin djangorestframework<3.12. That is what I am currently doing until the last couple of drf-yasg2 issues are fixed up and released onto PyPI.
Most helpful comment
Breaking for me even for 3.9.4. Installing packaging fixed it for me.
pip3 install packaging