Generating python documentation bug

The docs on the git repository for Anki give the suggestion of generating Python documentation using:
./ninja python:sphinx && open out/python/sphinx/html/py-modindex.html

I imagine this is only a Linux thing, trying to execute it on Windows (switching for tools\ninja, of course) just causes the following errors:
Traceback (most recent call last):
File “C:\Users\mahdi\Documents\anki\python\sphinx\build.py”, line 7, in
subprocess.run([“out/pyenv/bin/sphinx-apidoc”, “-o”, “out/python/sphinx”, “pylib”, “qt”], check=True)
~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “C:\Users\mahdi\AppData\Roaming\uv\python\cpython-3.13.5-windows-x86_64-none\Lib\subprocess.py”, line 554, in run
with Popen(*popenargs, **kwargs) as process:
~~~~~^^^^^^^^^^^^^^^^^^^^^^
File “C:\Users\mahdi\AppData\Roaming\uv\python\cpython-3.13.5-windows-x86_64-none\Lib\subprocess.py”, line 1039, in init
self._execute_child(args, executable, preexec_fn, close_fds,
~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
pass_fds, cwd, env,
^^^^^^^^^^^^^^^^^^^
…<5 lines>…
gid, gids, uid, umask,
^^^^^^^^^^^^^^^^^^^^^^
start_new_session, process_group)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “C:\Users\mahdi\AppData\Roaming\uv\python\cpython-3.13.5-windows-x86_64-none\Lib\subprocess.py”, line 1554, in _execute_child
hp, ht, pid, tid = _winapi.CreateProcess(executable, args,
~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^
# no special security
^^^^^^^^^^^^^^^^^^^^^
…<4 lines>…
cwd,
^^^^
startupinfo)
^^^^^^^^^^^^
FileNotFoundError: [WinError 2] Impossibile trovare il file specificato
Failed to run (1): out\pyenv\scripts\python.exe python/sphinx/build.py

And after that even building the program doesn’t work anymore

For reference, it’s here:

Should be a Linux and MacOS thing. I can confirm that the command works fine for me on debian linux.


tools\ninja.bat and ninja do the same things, though. So in theory it should work.

Judging by this:

Have you manually checked the existence of out\pyenv\scripts\python.exe and of python/sphinx/build.py?

Yes both of the files are there. Maybe it is because when using tolls\ninja the working directory is different? I don’t know how to test it, like returning the absolute path.

I checked better and the file causing the error is out/pyenv/bin/sphinx-apidoc which subprocess.run is strying to open but does in fact not exist and it is nowehre to be found so I doubt this is is an error being caused by relative paths as I supposed. The reason why it is missing is beyond my comprehension tho

1 Like

The build script assumes Linux, so it’s using out/pyenv/bin instead of the correct out/pyenv/scripts on Windows. It works if you edit the script (python/sphinx/build.py) manually.

1 Like