Running sphinx-build leads to AttributeError: 'Values' object has no attribute 'link_base'

Question:

I have a Django 4.2 project and wish to run Sphinx to generate the docs. When I run

sphinx-build -b html docs_source/ docs/

I got the following error:

Exception occurred:

File
"C:ProgramDataAnaconda3envsdjango_3_8Libsite-packagesdjangocontribadmindocsutils.py",
line 116, in _role

inliner.document.settings.link_base,

^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

AttributeError: ‘Values’ object has no attribute ‘link_base’

The full traceback has been saved in
C:UsersuserAppDataLocalTempsphinx-err-r_cbc4k5.log, if you want
to report the issue to the developers.

The list of the installed packages is as follows:

Package                       Version

----------------------------- ---------

alabaster                     0.7.13
amqp                          5.1.1
anyio                         3.5.0
argon2-cffi                   21.3.0
argon2-cffi-bindings          21.2.0
asgiref                       3.7.2
asttokens                     2.0.5
attrs                         22.1.0
autopep8                      1.6.0
Babel                         2.13.1
backcall                      0.2.0
beautifulsoup4                4.12.2
billiard                      3.6.4.0
bleach                        4.1.0
celery                        5.1.2
certifi                       2022.12.7
cffi                          1.15.1
charset-normalizer            3.3.2
click                         7.1.2
click-didyoumean              0.0.3
click-plugins                 1.1.1
click-repl                    0.2.0
colorama                      0.4.6
comm                          0.1.2
coverage                      7.2.2
cryptography                  39.0.1
debugpy                       1.5.1
decorator                     5.1.1
defusedxml                    0.7.1
diagrams                      0.23.3
Django                        4.2.7
django-debug-toolbar          4.0.0
django-nose                   1.4.6
django-postgres-extra         2.0.8
djangorestframework           3.14.0
djangorestframework-simplejwt 4.4.0
docutils                      0.20.1
drf-extra-fields              3.5.0
drf-spectacular               0.26.2
entrypoints                   0.4
et-xmlfile                    1.1.0
executing                     0.8.3
fastjsonschema                2.16.2
filetype                      1.2.0
graphviz                      0.20.1
idna                          3.4
imagesize                     1.4.1
inflection                    0.5.1
ipykernel                     6.19.2
ipython                       8.18.0
ipython-genutils              0.2.0
jedi                          0.18.1
Jinja2                        3.1.2
jsonschema                    4.17.3
jupyter_client                8.1.0
jupyter_core                  5.3.0
jupyter-server                1.23.4
jupyterlab-pygments           0.1.2
kombu                         5.3.1
lxml                          4.9.2
Mako                          1.3.0
Markdown                      3.5.1
MarkupSafe                    2.1.1
matplotlib-inline             0.1.6
mistune                       0.8.4
nbclassic                     0.5.5
nbclient                      0.5.13
nbconvert                     6.5.4
nbformat                      5.7.0
nest-asyncio                  1.5.6
nose                          1.3.7
notebook                      6.5.4
notebook_shim                 0.2.2
openpyxl                      3.0.10
packaging                     23.0
pandocfilters                 1.5.0
parso                         0.8.3
pdoc3                         0.10.0
pickleshare                   0.7.5
Pillow                        9.4.0
pip                           23.0.1
platformdirs                  2.5.2
prometheus-client             0.14.1
prompt-toolkit                3.0.36
psutil                        5.9.0
psycopg2                      2.9.3
pure-eval                     0.2.2
pycodestyle                   2.10.0
pycparser                     2.21
Pygments                      2.15.1
PyJWT                         2.4.0
pyOpenSSL                     23.1.1
pyrsistent                    0.18.0
python-dateutil               2.8.2
pytz                          2022.7
pywin32                       305.1
pywinpty                      2.0.10
PyYAML                        6.0
pyzmq                         25.0.2
redis                         3.5.3
requests                      2.31.0
scout-apm                     2.26.1
Send2Trash                    1.8.0
setuptools                    66.0.0
six                           1.16.0
sniffio                       1.2.0
snowballstemmer               2.2.0
soupsieve                     2.4
Sphinx                        7.2.6
sphinx-autodoc-typehints      1.25.2
sphinxcontrib-applehelp       1.0.7
sphinxcontrib-devhelp         1.0.5
sphinxcontrib-htmlhelp        2.0.4
sphinxcontrib-jsmath          1.0.1
sphinxcontrib-qthelp          1.0.6
sphinxcontrib-serializinghtml 1.1.9
sqlparse                      0.4.3
stack-data                    0.2.0
tblib                         3.0.0
terminado                     0.17.1
tinycss2                      1.2.1
toml                          0.10.2
tornado                       6.2
traitlets                     5.7.1
typed-ast                     1.5.4
typing_extensions             4.5.0
tzdata                        2021.1
uritemplate                   4.1.1
urllib3                       1.26.15
urllib3-secure-extra          0.1.0
vine                          5.0.0
wcwidth                       0.2.5
webencodings                  0.5.1
websocket-client              0.58.0
wheel                         0.38.4
wrapt                         1.15.0

Any hint?

I tried today with a fresh new environment, Phyton, Django and Sphinx. I got the same error message. I cannot paste here the Sphinx error message since this editor does not allow it….

Asked By: pittnerf

||

Answers:

I created a workaround in order to owercome this issue and go on with the document generation.

In the [conda environment path]Libsite-packagesdjangocontribadmindocsutils.py in the create_reference_role() function, I replaced

        node = docutils.nodes.reference(
            rawtext,
            text,
            refuri=(
                urlbase
                % (
                    inliner.document.settings.link_base,
                    text.lower(),
                )
            ),
            **options,
        )

with

try:
        node = docutils.nodes.reference(
            rawtext,
            text,
            refuri=(
                urlbase
                % (
                    inliner.document.settings.link_base,
                    text.lower(),
                )
            ),
            **options,
        )

    except AttributeError:
        node = docutils.nodes.reference(
            rawtext,
            text,
            refuri=None,
            **options,
        )
Answered By: pittnerf
Categories: questions Tags: , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.