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 'add_js_files' from 'sphinxcontrib.jquery' #11450

Closed
rzehumat opened this issue Jun 1, 2023 · 3 comments
Closed

Comments

@rzehumat
Copy link

rzehumat commented Jun 1, 2023

Describe the bug

When running sphinx-build, a following error is raiser
(for the sake of privacy I've put the <var> placeholders, hope it's not a problem)

<user>@<machine>:~/<path>/doc$ sphinx-build source build
Running Sphinx v6.2.1
making output directory... done
checking bibtex cache... out of date
parsing bibtex file /home/<path>/doc/source/references.bib... parsed 119 entries

Exception occurred:
  File "/home/<user>/.local/lib/python3.10/site-packages/sphinx_rtd_theme/__init__.py", line 63, in setup
    from sphinxcontrib.jquery import add_js_files as jquery_add_js_files
ImportError: cannot import name 'add_js_files' from 'sphinxcontrib.jquery' (/home/<user>/.local/lib/python3.10/site-packages/sphinxcontrib/jquery.py)
The full traceback has been saved in /tmp/sphinx-err-gcnpg9tw.log, if you want to report the issue to the developers.
Please also report this if it was a user error, so that a better error message can be provided next time.
A bug report can be filed in the tracker at <https://github.com/sphinx-doc/sphinx/issues>. Thanks!

Full traceback from abovementioned file is attached later.

Last messages:

<user>@<machine>:~/<path>/doc$ sphinx-build source build
Running Sphinx v6.2.1
making output directory... done
checking bibtex cache... out of date
parsing bibtex file /home/<path>/doc/source/references.bib... parsed 119 entries

Exception occurred:
  File "/home/<user>/.local/lib/python3.10/site-packages/sphinx_rtd_theme/__init__.py", line 63, in setup
    from sphinxcontrib.jquery import add_js_files as jquery_add_js_files
ImportError: cannot import name 'add_js_files' from 'sphinxcontrib.jquery' (/home/<user>/.local/lib/python3.10/site-packages/sphinxcontrib/jquery.py)
The full traceback has been saved in /tmp/sphinx-err-gcnpg9tw.log, if you want to report the issue to the developers.
Please also report this if it was a user error, so that a better error message can be provided next time.
A bug report can be filed in the tracker at <https://github.com/sphinx-doc/sphinx/issues>. Thanks!

Loaded extensions:

extensions = ['myst_parser',
              'sphinx_rtd_dark_mode',
              'sphinxcontrib.bibtex']
default_dark_mode = True
bibtex_bibfiles = ['references.bib']

Traceback:

# Platform:         linux; (Linux-5.15.0-57-generic-x86_64-with-glibc2.35)
# Sphinx version:   6.2.1
# Python version:   3.10.6 (CPython)
# Docutils version: 0.18.1
# Jinja2 version:   3.1.2
# Pygments version: 2.15.1


Traceback (most recent call last):
  File "/home/<>/.local/lib/python3.10/site-packages/sphinx/cmd/build.py", line 280, in build_main
    app = Sphinx(args.sourcedir, args.confdir, args.outputdir,
  File "/home/<user>/.local/lib/python3.10/site-packages/sphinx/application.py", line 268, in __init__
    self._init_builder()
  File "/home/<user>/.local/lib/python3.10/site-packages/sphinx/application.py", line 340, in _init_builder
    self.builder.init()
  File "/home/<user>/.local/lib/python3.10/site-packages/sphinx/builders/html/__init__.py", line 253, in init
    self.init_templates()
  File "/home/<user>/.local/lib/python3.10/site-packages/sphinx/builders/html/__init__.py", line 304, in init_templates
    self.theme = theme_factory.create(themename)
  File "/home/<user>/.local/lib/python3.10/site-packages/sphinx/theming.py", line 225, in create
    self.load_extra_theme(name)
  File "/home/<user>/.local/lib/python3.10/site-packages/sphinx/theming.py", line 179, in load_extra_theme
    self.load_external_theme(name)
  File "/home/<user>/.local/lib/python3.10/site-packages/sphinx/theming.py", line 195, in load_external_theme
    self.app.registry.load_extension(self.app, entry_point.module)
  File "/home/<user>/.local/lib/python3.10/site-packages/sphinx/registry.py", line 455, in load_extension
    metadata = setup(app)
  File "/home/<user>/.local/lib/python3.10/site-packages/sphinx_rtd_theme/__init__.py", line 63, in setup
    from sphinxcontrib.jquery import add_js_files as jquery_add_js_files
ImportError: cannot import name 'add_js_files' from 'sphinxcontrib.jquery' (/home/<user>/.local/lib/python3.10/site-packages/sphinxcontrib/jquery.py)


How to Reproduce

index.rst



.. library documentation master file, created by
   sphinx-quickstart on Thu Apr 27 17:55:14 2023.
   You can adapt this file completely to your liking, but it should at least
   contain the root `toctree` directive.

Library for <lib_name>
===================================

.. toctree::
   :maxdepth: 2
   :caption: Fuel families:

   
   <file1>.rst

   <file2>.rst

   <file3>.rst

   <file4>.rst

   <file5>.rst
   

   references.rst



Indices and tables
==================

* :ref:`genindex`
* :ref:`modindex`
* :ref:`search`

conf.py

import json
from glob import glob

# Configuration file for the Sphinx documentation builder.
#
# For the full list of built-in configuration values, see the documentation:
# https://www.sphinx-doc.org/en/master/usage/configuration.html

# -- Project information -----------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#project-information

# this is here just for the sake of defining `project` variable below 
possible_jsons = glob("../../*_compiled.json")
if len(possible_jsons) == 1:
    with open(possible_jsons[0]) as f:
        lib_obj = json.load(f)
else:
    raise FileExistsError(f"More than 1 json file found -- {possible_jsons}.")

project = lib_obj["description"]
copyright = '2023, rzehumat'
author = 'rzehumat'
release = '0'

# -- General configuration ---------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration

extensions = ['myst_parser',
              'sphinx_rtd_dark_mode',
              'sphinxcontrib.bibtex']
default_dark_mode = True
bibtex_bibfiles = ['references.bib']

templates_path = ['_templates']
exclude_patterns = []


# -- Options for HTML output -------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#options-for-html-output

html_theme = 'sphinx_rtd_theme'
html_static_path = ['_static']

Environment Information

Actually, suggested `pip install -U "sphinx>=5.3"` raises

Installing collected packages: sphinx
  Attempting uninstall: sphinx
    Found existing installation: Sphinx 6.2.1
    Uninstalling Sphinx-6.2.1:
      Successfully uninstalled Sphinx-6.2.1
ERROR: pip's dependency resolver does not currently take into account all the packages that are installed. This behaviour is the source of the following dependency conflicts.
myst-parser 1.0.0 requires sphinx<7,>=5, but you have sphinx 7.0.1 which is incompatible.
sphinx-rtd-theme 1.2.1 requires sphinx<7,>=1.6, but you have sphinx 7.0.1 which is incompatible.
Successfully installed sphinx-7.0.1

So I have tried a compatible version pip install sphinx==6.2.1 and after sphinx-build --bug-report:

Platform:              linux; (Linux-5.15.0-57-generic-x86_64-with-glibc2.35)
Python version:        3.10.6 (main, Nov 14 2022, 16:10:14) [GCC 11.3.0])
Python implementation: CPython
Sphinx version:        6.2.1
Docutils version:      0.18.1
Jinja2 version:        3.1.2
Pygments version:      2.15.1

Sphinx extensions

python
extensions = ['myst_parser',
              'sphinx_rtd_dark_mode',
              'sphinxcontrib.bibtex']
default_dark_mode = True
bibtex_bibfiles = ['references.bib']

Additional context

Mentioned <file>N.rst contains only rst with bibliography references by sphinxcontrib.bibtex like :cite:someKeyInBibTex:

references.rst contains

References
==========

.. bibliography::
@rzehumat
Copy link
Author

rzehumat commented Jun 1, 2023

I wonder if it might have something to do with the myst-parser and sphinx-rtd-theme dependency issues...

@benjaoming
Copy link
Contributor

Hi @rzehumat 👋 This is likely an issue from sphinx-rtd-theme. What seems to have happened is that you already had sphinxcontrib-jquery installed in an older version when sphinx-rtd-theme got installed or upgraded.

You should be able to fix this by running pip install 'sphinxcontrib-jquery>=4'

The fix is merged but not released: readthedocs/sphinx_rtd_theme#1446

@rzehumat
Copy link
Author

rzehumat commented Jun 1, 2023

Hi @benjaoming , awesome, thanks a lot.

You should be able to fix this by running pip install 'sphinxcontrib-jquery>=4'

That solved the issue

@rzehumat rzehumat closed this as completed Jun 1, 2023
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jul 2, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants