Skip to content

autodoc: cannot import name 'mock' from 'sphinx.ext.autodoc'  #14142

@stefanseefeld

Description

@stefanseefeld

Describe the bug

I'm seeing the below error running sphinx. All the relevant info should be part of the log.

How to Reproduce

Running Sphinx v9.0.1
loading translations [python]... not available for built-in messages

Extension error!

Versions
========

* Platform:         linux; (Linux-6.17.0-6-generic-x86_64-with-glibc2.39)
* Python version:   3.12.3 (CPython)
* Sphinx version:   9.0.1
* Docutils version: 0.22.3
* Jinja2 version:   3.1.6
* Pygments version: 2.19.2

Last Messages
=============

None.

Loaded Extensions
=================

None.

Traceback
=========

      File "/home/user/.local/lib/python3.12/site-packages/sphinx/registry.py", line 546, in load_extension
        raise ExtensionError(
    sphinx.errors.ExtensionError: Could not import extension sphinxarg.ext (exception: cannot import name 'mock' from 'sphinx.ext.autodoc' (/home/user/.local/lib/python3.12/site-packages/sphinx/ext/autodoc/__init__.py))


The full traceback has been saved in:
/tmp/sphinx-err-i2e2sw7c.log

To report this error to the developers, please open an issue at <https://github.com/sphinx-doc/sphinx/issues/>. Thanks!
Please also report this if it was a user error, so that a better error message can be provided next time.

and just for completeness:

user@nemo:~/srcdir$ pip list | grep sphinx
sphinx-argparse               0.5.2
sphinxcontrib-applehelp       2.0.0
sphinxcontrib-devhelp         2.0.0
sphinxcontrib-htmlhelp        2.1.0
sphinxcontrib-jsmath          1.0.1
sphinxcontrib-qthelp          2.0.0
sphinxcontrib-serializinghtml 2.0.0

Environment Information

I'm running this in an ubuntu 24.04 container, with


Platform:              linux; (Linux-6.17.0-6-generic-x86_64-with-glibc2.39)
Python version:        3.12.3 (main, Nov  6 2025, 13:44:16) [GCC 13.3.0])
Python implementation: CPython
Sphinx version:        9.0.1
Docutils version:      0.22.3
Jinja2 version:        3.1.6
Pygments version:      2.19.2

Sphinx extensions

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions