Skip to content
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

ImportError: cannot import name 'default_handlers' from 'openapi_spec_validator' #733

Closed
MPParsley opened this issue Nov 4, 2022 · 5 comments
Assignees
Milestone

Comments

@MPParsley
Copy link

When running the python server the following error is thrown:

atramhasis_demo % pserve development.ini   
Traceback (most recent call last):
  File "/usr/local/bin/pserve", line 8, in <module>
    sys.exit(main())
  File "/usr/local/lib/python3.9/site-packages/pyramid/scripts/pserve.py", line 30, in main
    return command.run()
  File "/usr/local/lib/python3.9/site-packages/pyramid/scripts/pserve.py", line 271, in run
    app = loader.get_wsgi_app(app_name, config_vars)
  File "/usr/local/lib/python3.9/site-packages/plaster_pastedeploy/__init__.py", line 125, in get_wsgi_app
    return loadapp(
  File "/usr/local/lib/python3.9/site-packages/paste/deploy/loadwsgi.py", line 248, in loadapp
    return loadobj(APP, uri, name=name, **kw)
  File "/usr/local/lib/python3.9/site-packages/paste/deploy/loadwsgi.py", line 273, in loadobj
    return context.create()
  File "/usr/local/lib/python3.9/site-packages/paste/deploy/loadwsgi.py", line 741, in create
    return self.object_type.invoke(self)
  File "/usr/local/lib/python3.9/site-packages/paste/deploy/loadwsgi.py", line 138, in invoke
    return fix_call(context.object, context.global_conf, **context.local_conf)
  File "/usr/local/lib/python3.9/site-packages/paste/deploy/util.py", line 61, in fix_call
    val = callable(*args, **kw)
  File "/Volumes/webdev/www/district09/opendata/atramhasis_demo/atramhasis_demo/__init__.py", line 38, in main
    config.include("atramhasis")
  File "/usr/local/lib/python3.9/site-packages/pyramid/config/__init__.py", line 666, in include
    c(configurator)
  File "/usr/local/lib/python3.9/site-packages/atramhasis/__init__.py", line 18, in includeme
    config.include("pyramid_openapi3")
  File "/usr/local/lib/python3.9/site-packages/pyramid/config/__init__.py", line 632, in include
    c = self.maybe_dotted(callable)
  File "/usr/local/lib/python3.9/site-packages/pyramid/config/__init__.py", line 740, in maybe_dotted
    return self.name_resolver.maybe_resolve(dotted)
  File "/usr/local/lib/python3.9/site-packages/pyramid/path.py", line 327, in maybe_resolve
    return self._resolve(dotted, package)
  File "/usr/local/lib/python3.9/site-packages/pyramid/path.py", line 334, in _resolve
    return self._zope_dottedname_style(dotted, package)
  File "/usr/local/lib/python3.9/site-packages/pyramid/path.py", line 383, in _zope_dottedname_style
    found = __import__(used)
  File "/usr/local/lib/python3.9/site-packages/pyramid_openapi3/__init__.py", line 3, in <module>
    from .exceptions import extract_errors
  File "/usr/local/lib/python3.9/site-packages/pyramid_openapi3/exceptions.py", line 3, in <module>
    from openapi_core.schema.exceptions import OpenAPIError
  File "/usr/local/lib/python3.9/site-packages/openapi_core/__init__.py", line 3, in <module>
    from openapi_core.shortcuts import (
  File "/usr/local/lib/python3.9/site-packages/openapi_core/shortcuts.py", line 3, in <module>
    from openapi_core.schema.shortcuts import create_spec
  File "/usr/local/lib/python3.9/site-packages/openapi_core/schema/shortcuts.py", line 3, in <module>
    from openapi_spec_validator import (
ImportError: cannot import name 'default_handlers' from 'openapi_spec_validator' (/usr/local/lib/python3.9/site-packages/openapi_spec_validator/__init__.py)
@MPParsley
Copy link
Author

MPParsley commented Nov 4, 2022

Current workaround:

openapi-spec-validator==0.4.0

See Pylons/pyramid_openapi3#173

Next issue is

atramhasis_demo % pserve development.ini

Traceback (most recent call last):
  File "/usr/local/lib/python3.9/site-packages/pyramid/config/actions.py", line 307, in execute_actions
    callable(*args, **kw)
  File "/usr/local/lib/python3.9/site-packages/pyramid_jinja2/__init__.py", line 449, in register
    env = create_environment_from_options(env_opts, loader_opts)
  File "/usr/local/lib/python3.9/site-packages/pyramid_jinja2/__init__.py", line 401, in create_environment_from_options
    env = Environment(loader=loader, **env_opts)
  File "/usr/local/lib/python3.9/site-packages/jinja2/environment.py", line 363, in __init__
    self.extensions = load_extensions(self, extensions)
  File "/usr/local/lib/python3.9/site-packages/jinja2/environment.py", line 117, in load_extensions
    extension = t.cast(t.Type["Extension"], import_string(extension))
  File "/usr/local/lib/python3.9/site-packages/jinja2/utils.py", line 149, in import_string
    return getattr(__import__(module, None, None, [obj]), obj)
AttributeError: module 'jinja2.ext' has no attribute 'with_'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/bin/pserve", line 8, in <module>
    sys.exit(main())
  File "/usr/local/lib/python3.9/site-packages/pyramid/scripts/pserve.py", line 30, in main
    return command.run()
  File "/usr/local/lib/python3.9/site-packages/pyramid/scripts/pserve.py", line 271, in run
    app = loader.get_wsgi_app(app_name, config_vars)
  File "/usr/local/lib/python3.9/site-packages/plaster_pastedeploy/__init__.py", line 125, in get_wsgi_app
    return loadapp(
  File "/usr/local/lib/python3.9/site-packages/paste/deploy/loadwsgi.py", line 248, in loadapp
    return loadobj(APP, uri, name=name, **kw)
  File "/usr/local/lib/python3.9/site-packages/paste/deploy/loadwsgi.py", line 273, in loadobj
    return context.create()
  File "/usr/local/lib/python3.9/site-packages/paste/deploy/loadwsgi.py", line 741, in create
    return self.object_type.invoke(self)
  File "/usr/local/lib/python3.9/site-packages/paste/deploy/loadwsgi.py", line 138, in invoke
    return fix_call(context.object, context.global_conf, **context.local_conf)
  File "/usr/local/lib/python3.9/site-packages/paste/deploy/util.py", line 61, in fix_call
    val = callable(*args, **kw)
  File "/Volumes/webdev/www/district09/opendata/atramhasis_demo/atramhasis_demo/__init__.py", line 53, in main
    return config.make_wsgi_app()
  File "/usr/local/lib/python3.9/site-packages/pyramid/config/__init__.py", line 891, in make_wsgi_app
    self.commit()
  File "/usr/local/lib/python3.9/site-packages/pyramid/config/actions.py", line 151, in commit
    self.action_state.execute_actions(introspector=self.introspector)
  File "/usr/local/lib/python3.9/site-packages/pyramid/config/actions.py", line 311, in execute_actions
    reraise(
  File "/usr/local/lib/python3.9/site-packages/pyramid/util.py", line 732, in reraise
    raise value.with_traceback(tb)
  File "/usr/local/lib/python3.9/site-packages/pyramid/config/actions.py", line 307, in execute_actions
    callable(*args, **kw)
  File "/usr/local/lib/python3.9/site-packages/pyramid_jinja2/__init__.py", line 449, in register
    env = create_environment_from_options(env_opts, loader_opts)
  File "/usr/local/lib/python3.9/site-packages/pyramid_jinja2/__init__.py", line 401, in create_environment_from_options
    env = Environment(loader=loader, **env_opts)
  File "/usr/local/lib/python3.9/site-packages/jinja2/environment.py", line 363, in __init__
    self.extensions = load_extensions(self, extensions)
  File "/usr/local/lib/python3.9/site-packages/jinja2/environment.py", line 117, in load_extensions
    extension = t.cast(t.Type["Extension"], import_string(extension))
  File "/usr/local/lib/python3.9/site-packages/jinja2/utils.py", line 149, in import_string
    return getattr(__import__(module, None, None, [obj]), obj)
pyramid.exceptions.ConfigurationExecutionError: <class 'AttributeError'>: module 'jinja2.ext' has no attribute 'with_'
  in:
  Line 488 of file /usr/local/lib/python3.9/site-packages/pyramid_jinja2/__init__.py:
    config.add_jinja2_renderer(".jinja2", package=package)

Workaround, require:

jinja2<3
markupsafe<2

See TeamHG-Memex/eli5#416

@koenedaele
Copy link
Member

How did you install? The latest version (1.2.0) has openapi-spec-validator==0.4.0 in the requirements file. Did you try a different version?

@MPParsley
Copy link
Author

MPParsley commented Nov 29, 2022

@koenedaele, I installed as documented on

There are slight differences between both documentations.

I had to add these in order to run:

    'pyramid_openapi3',
    'openapi-spec-validator==0.4.0',
    'jinja2<3',
    'markupsafe<2',

I assume the problem is that the docs refer to https://github.com/OnroerendErfgoed/atramhasis_demo_cookiecutter and there these dependencies are still missing in https://github.com/OnroerendErfgoed/atramhasis_demo_cookiecutter/blob/main/%7B%7Bcookiecutter.repo%7D%7D/setup.py

@koenedaele koenedaele added this to the Sprint 220 milestone Nov 19, 2023
@koenedaele
Copy link
Member

@Wim-De-Clercq Is this still an issue with v2?

@Wim-De-Clercq
Copy link
Contributor

The v2 branch has this feature #784 so the jinja2 and markupsafe requirements will be fine with that.
The openapi-spec-validator==0.4.0 should already be part of atramhasis since 1.3.0.
The pyramid_openapi3 requirement is already part of atramhasis since 1.1.0.

However, due to Pylons/pyramid_openapi3#206 we may want to already restrict it to <0.17 because that's definitely going to break things.

@cedrikv cedrikv modified the milestones: Sprint 220, Sprint 221 Nov 20, 2023
@cedrikv cedrikv modified the milestones: Sprint 221, Sprint 222 Dec 4, 2023
@cedrikv cedrikv modified the milestones: Sprint 222, Sprint 223 Dec 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants