Page MenuHomePhabricator

Requirements.txt does not list graphviz as a required package for category_graph.py
Closed, ResolvedPublic

Description

graphviz is a required component for category_graph.py to run. This is not mentioned in the pywikibot Requirements.txt file and is not installed as part of the standard pywikibot installation.

Without graphviz, a FileNotFoundError with message "[WinError2] "dot" not found in path." will occur when running pwb.py -v category_graph -from.

Full Traceback

Exception has occurred: FileNotFoundError
[WinError 2] "dot" not found in path.
FileNotFoundError: [WinError 2] The system cannot find the file specified

During handling of the above exception, another exception occurred:

  File "C:\git\core\scripts\category_graph.py", line 181, in run
    self.dot.write_svg(self.to + '.svg', encoding='utf-8')
  File "C:\git\core\scripts\category_graph.py", line 209, in <module>
    bot.run()
  File "C:\git\core\pywikibot\scripts\wrapper.py", line 147, in run_python_file
    exec(compile(source, filename, 'exec', dont_inherit=True),
  File "C:\git\core\pywikibot\scripts\wrapper.py", line 484, in execute
    run_python_file(filename, script_args, module)
  File "C:\git\core\pywikibot\scripts\wrapper.py", line 497, in main
    if not execute():
           ^^^^^^^^^
  File "C:\git\core\pywikibot\scripts\wrapper.py", line 513, in <module>
    main()
  File "C:\git\core\pwb.py", line 35, in main
    runpy.run_path(str(path), run_name='__main__')
  File "C:\git\core\pwb.py", line 39, in <module>
    sys.exit(main())
             ^^^^^^
FileNotFoundError: [WinError 2] "dot" not found in path.

This should be added to the Requirements.txt file under the section for interwiki_graph.py and category_graph.py.

Event Timeline

Xqt removed Enag2000 as the assignee of this task.EditedFeb 1 2026, 11:35 AM
Xqt triaged this task as Low priority.
Xqt subscribed.

pydot is already listed in requirements.txt but Graphviz is not a Python package and must be installed separately.

See:

Anyway it would be more helpful if the code provided a clear message about the missing Graphviz installation instead of raising a FileNotFoundError.

The current exception is:

C:\pwb\GIT\core>py -3.13 -m pwb -simulate category_graph -from -to data
Scanning 'Main topic classifications'
Saving results
data.gv
data.svg
Traceback (most recent call last):
  File "C:\Python\Python313\Lib\site-packages\pydot\core.py", line 1824, in create
    stdout_data, stderr_data, process = call_graphviz(
                                        ~~~~~~~~~~~~~^
        program=prog,
        ^^^^^^^^^^^^^
        arguments=arguments,
        ^^^^^^^^^^^^^^^^^^^^
        working_dir=tmp_dir,
        ^^^^^^^^^^^^^^^^^^^^
    )
    ^
  File "C:\Python\Python313\Lib\site-packages\pydot\core.py", line 249, in call_graphviz
    process = subprocess.Popen(
        program_with_args,
    ...<5 lines>...
        **kwargs,
    )
  File "C:\Python\Python313\Lib\subprocess.py", line 1036, 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:\Python\Python313\Lib\subprocess.py", line 1548, in _execute_child
    hp, ht, pid, tid = _winapi.CreateProcess(executable, args,
                       ~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^
                             # no special security
                             ^^^^^^^^^^^^^^^^^^^^^
    ...<4 lines>...
                             cwd,
                             ^^^^
                             startupinfo)
                             ^^^^^^^^^^^^
FileNotFoundError: [WinError 2] Das System kann die angegebene Datei nicht finden

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "C:\pwb\GIT\core\pwb.py", line 40, in <module>
    sys.exit(main())
             ~~~~^^
  File "C:\pwb\GIT\core\pwb.py", line 36, in main
    runpy.run_path(str(path), run_name='__main__')
    ~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "<frozen runpy>", line 287, in run_path
  File "<frozen runpy>", line 98, in _run_module_code
  File "<frozen runpy>", line 88, in _run_code
  File "C:\pwb\GIT\core\pywikibot\scripts\wrapper.py", line 566, in <module>
    main()
    ~~~~^^
  File "C:\pwb\GIT\core\pywikibot\scripts\wrapper.py", line 550, in main
    if not execute():
           ~~~~~~~^^
  File "C:\pwb\GIT\core\pywikibot\scripts\wrapper.py", line 537, in execute
    run_python_file(filename, script_args, module)
    ~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\pwb\GIT\core\pywikibot\scripts\wrapper.py", line 154, in run_python_file
    exec(compile(source, filename, 'exec', dont_inherit=True),
    ~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
         main_mod.__dict__)
         ^^^^^^^^^^^^^^^^^^
  File "C:\pwb\GIT\core\scripts\category_graph.py", line 258, in <module>
    main()
    ~~~~^^
  File "C:\pwb\GIT\core\scripts\category_graph.py", line 254, in main
    bot.run()
    ~~~~~~~^^
  File "C:\pwb\GIT\core\scripts\category_graph.py", line 198, in run
    self.dot.write_svg(self.to + '.svg', encoding='utf-8')
    ~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Python\Python313\Lib\site-packages\pydot\core.py", line 195, in __write_method
    self.write(path, format=f, prog=prog, encoding=encoding)
    ~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Python\Python313\Lib\site-packages\pydot\core.py", line 1730, in write
    s = self.create(prog, format, encoding=encoding)
  File "C:\Python\Python313\Lib\site-packages\pydot\core.py", line 1833, in create
    raise OSError(*args)
FileNotFoundError: [WinError 2] "dot" not found in path.
CRITICAL: Exiting due to uncaught exception FileNotFoundError: [WinError 2] "dot" not found in path.

Change #1235555 had a related patch set uploaded (by Xqt; author: Xqt):

[pywikibot/core@master] IMPR: Show a gracefull warning if Graphviz is not installed

https://gerrit.wikimedia.org/r/1235555

Change #1235555 merged by jenkins-bot:

[pywikibot/core@master] IMPR: Show a gracefull warning if Graphviz is not installed

https://gerrit.wikimedia.org/r/1235555