Skip to content

Converter detection fails for inkscape if on headless system without DISPLAY #17354

@jat255

Description

@jat255

Bug report

Bug summary

When running mpl._get_executable_info('inkscape') on a system where DISPLAY is defined but non-accessible (such as a remote system running a local X server), the method bombs with subprocess.CalledProcessError: Command '['inkscape', '-V']' returned non-zero exit status 1.

Code for reproduction

import matplotlib
matplotlib._get_executable_info('inkscape')

Actual outcome

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/jat/.conda/envs/hyperspy_dev/lib/python3.8/site-packages/matplotlib/__init__.py", line 357, in _get_executable_info
    return impl(["inkscape", "-V"], "^Inkscape ([^ ]*)")
  File "/home/jat/.conda/envs/hyperspy_dev/lib/python3.8/site-packages/matplotlib/__init__.py", line 330, in impl
    raise _cpe
  File "/home/jat/.conda/envs/hyperspy_dev/lib/python3.8/site-packages/matplotlib/__init__.py", line 323, in impl
    output = subprocess.check_output(
  File "/home/jat/.conda/envs/hyperspy_dev/lib/python3.8/subprocess.py", line 411, in check_output
    return run(*popenargs, stdout=PIPE, timeout=timeout, check=True,
  File "/home/jat/.conda/envs/hyperspy_dev/lib/python3.8/subprocess.py", line 512, in run
    raise CalledProcessError(retcode, process.args,
subprocess.CalledProcessError: Command '['inkscape', '-V']' returned non-zero exit status 1.

Expected outcome

Even if DISPLAY is not available, detection of headless inkscape should work

Matplotlib version

  • Operating system: Linux 5.3.0 - Ubuntu 18.04
  • Matplotlib version: 3.1.3 (although this is a problem in the latest version as well)
  • Matplotlib backend (print(matplotlib.get_backend())): Qt5Agg
  • Python version: 3.8.2 (Anaconda)

Installed via conda using the conda-forge channel

Additional info

This can be fixed by calling Inkscape in headless mode, rather than interactive mode:

$ inkscape -V

(inkscape:11828): Gtk-WARNING **: 11:14:28.713: cannot open display: :0

vs.

$ inkscape -z -V
Inkscape 0.92.3 (2405546, 2018-03-11)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions