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

TypeError: entry_points() got an unexpected keyword argument 'group' #10479

Closed
martinobertoni opened this issue May 27, 2022 · 3 comments · Fixed by #11270
Closed

TypeError: entry_points() got an unexpected keyword argument 'group' #10479

martinobertoni opened this issue May 27, 2022 · 3 comments · Fixed by #11270

Comments

@martinobertoni
Copy link

Describe the bug

when running sphinx-build I get the following error:

Running Sphinx v4.5.0
making output directory... done

Traceback (most recent call last):
File "/opt/miniconda3/envs/py37/lib/python3.7/site-packages/sphinx/cmd/build.py", line 275, in build_main
args.tags, args.verbosity, args.jobs, args.keep_going)
File "/opt/miniconda3/envs/py37/lib/python3.7/site-packages/sphinx/application.py", line 256, in init
self._init_builder()
File "/opt/miniconda3/envs/py37/lib/python3.7/site-packages/sphinx/application.py", line 314, in _init_builder
self.builder.init()
File "/opt/miniconda3/envs/py37/lib/python3.7/site-packages/sphinx/builders/html/init.py", line 212, in init
self.init_templates()
File "/opt/miniconda3/envs/py37/lib/python3.7/site-packages/sphinx/builders/html/init.py", line 260, in init_templates
self.theme = theme_factory.create(themename)
File "/opt/miniconda3/envs/py37/lib/python3.7/site-packages/sphinx/theming.py", line 232, in create
self.load_extra_theme(name)
File "/opt/miniconda3/envs/py37/lib/python3.7/site-packages/sphinx/theming.py", line 177, in load_extra_theme
self.load_external_theme(name)
File "/opt/miniconda3/envs/py37/lib/python3.7/site-packages/sphinx/theming.py", line 199, in load_external_theme
theme_entry_points = entry_points(group='sphinx.html_themes')
TypeError: entry_points() got an unexpected keyword argument 'group'

How to Reproduce

make docs

Expected behavior

No response

Your project

https://gitlabsbnb.irbbarcelona.org/packages/chemical_checker/-/tree/master/package/docs

Screenshots

No response

OS

ubuntu 20.04

Python version

3.7

Sphinx version

4.5.0

Sphinx extensions

autodoc

Extra tools

No response

Additional context

No response

@AA-Turner
Copy link
Member

What does conda list show? I imagine you have importlib_metadata 3.5.0 or earlier -- you need to update.

A

@pmhahn
Copy link

pmhahn commented Nov 21, 2022

The same happens on Debian-11-Buster when python3-importlib-metadata v1.6.0 is installed:

>>> import importlib_metadata 
>>> importlib_metadata.__file__
'/usr/lib/python3/dist-packages/importlib_metadata/__init__.py'
>>> import importlib.metadata
>>> importlib.metadata.__file__
'/usr/lib/python3.9/importlib/metadata.py'
dpkg -S /usr/lib/python3/dist-packages/importlib_metadata/__init__.py /usr/lib/python3.9/importlib/metadata.py
# python3-importlib-metadata: /usr/lib/python3/dist-packages/importlib_metadata/__init__.py
# libpython3.9-minimal:amd64: /usr/lib/python3.9/importlib/metadata.py
dpkg-query -W python3-importlib-metadata libpython3.9-minimal
# libpython3.9-minimal:amd64      3.9.2-1
# python3-importlib-metadata      1.6.0-2

Looking at importlib_metadata there is not group argument.

The Python library documentation even has a "Compatibility Note" section as its end:

The “selectable” entry points were introduced in importlib_metadata 3.6 and Python 3.10. Prior to those changes, entry_points accepted no parameters and always returned a dictionary of entry points, keyed by group. For compatibility, if no parameters are passed to entry_points, a SelectableGroups object is returned, implementing that dict interface. In the future, calling entry_points with no parameters will return an EntryPoints object. Users should rely on the selection interface to retrieve entry points by group.

To support older Python version with older versions of importlib_metdata the code can be changed this way:

--- sphinx/theming.py
+++ sphinx/theming.py
@@ -190,1 +190,4 @@
-        theme_entry_points = entry_points(group='sphinx.html_themes')
+        try:
+            theme_entry_points = entry_points(group='sphinx.html_themes')
+        except TypeError:
+            theme_entry_points = {mod.name: mod for mod in entry_points().get("sphinx.html_themes", ())}

gnn added a commit to openego/eGon-data that referenced this issue Feb 7, 2023
For Pythons < 3.9, the Sphinx version needs to be constrained. Otherwise
it errors out with:

   TypeError: entry_points() got an unexpected keyword argument 'group'

due to Sphinx issue #10479.
Higher Python versions use Sphinx versions which are so up to date,
they get other errors with our documentation. So all in all, we need the
constraint to not run in any weird errors when building the
documentation for now.

[0]: sphinx-doc/sphinx#10479
@panhongtao07
Copy link
Contributor

I believe there's user who can't update importlib_metadata. I find the same error using Python 3.11, which is not expected especially when I installed more package to support sphinx. We should use importlib.metadata with priority after Python 3.10.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants