Skip to content

Commit 1a06ba4

Browse files
Better error handling if conversion to SVG fails (#561)
* tex_file_writing.py: better output in case conversion to SVG failed * troubleshooting.rst: What to do if PDF->SVG conversion fails * added small detail to troubleshooting dvisvgm * code-block cmd vs. bash for windows Co-authored-by: Naveen M K <[email protected]> * add anchor and link to dvisvgm homepage Co-authored-by: Naveen M K <[email protected]>
1 parent ed33fcc commit 1a06ba4

File tree

2 files changed

+73
-0
lines changed

2 files changed

+73
-0
lines changed

docs/source/installation/troubleshooting.rst

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,66 @@ uses. Which can be done by running:
1212
.. code-block:: bash
1313
1414
fmtutil -sys --all
15+
16+
17+
.. _dvisvgm-troubleshoot:
18+
19+
Installation does not support converting PDF to SVG?
20+
----------------------------------------------------
21+
22+
First, make sure your ``dvisvgm`` version is at least 2.4:
23+
24+
.. code-block:: bash
25+
26+
dvisvgm --version
27+
28+
29+
If you do not know how to update ``dvisvgm``, please refer to your operating system's documentation.
30+
31+
Second, check whether your ``dvisvgm`` supports PostScript specials. This is needed in order to convert from PDF to SVG.
32+
33+
.. code-block:: bash
34+
35+
dvisvgm -l
36+
37+
38+
If the output to this command does **not** contain ``ps dvips PostScript specials``, this is a bad sign.
39+
In this case, run
40+
41+
.. code-block:: bash
42+
43+
dvisvgm -h
44+
45+
46+
If the output does **not** contain ``--libgs=filename``, this means your ``dvisvgm`` does not currently support PostScript. You must get another binary.
47+
48+
If, however, ``--libgs=filename`` appears in the help, that means that your ``dvisvgm`` needs the Ghostscript library in order to support PostScript. Search for ``libgs.so`` (on Linux, probably in ``/usr/local/lib`` or ``/usr/lib``) or ``gsdll32.dll`` (on 32-bit Windows, probably in ``C:\windows\system32``) or ``gsdll64.dll`` (on 64-bit Windows, probably in ``c:\windows\system32`` -- yes 32) or ``libgsl.dylib`` (on Mac OS, probably in ``/usr/local/lib`` or ``/opt/local/lib``). Please look carefully, as the file might be located elsewhere, e.g. in the directory where Ghostscript is installed.
49+
50+
As soon as you have found the library, try (on Mac OS or Linux)
51+
52+
.. code-block:: bash
53+
54+
export LIBS=<path to your library including the file name>
55+
dvisvgm -l
56+
57+
or (on Windows)
58+
59+
.. code-block:: cmd
60+
61+
set LIBS=<path to your library including the file name>
62+
dvisvgm -l
63+
64+
65+
You should now see ``ps dvips PostScript specials`` in the output. Refer to your operating system's documentation in order to find out how you can set or export the environment variable ``LIBGS`` automatically whenever you open a shell.
66+
67+
As a last check, you can run
68+
69+
.. code-block:: bash
70+
71+
dvisvgm -V1
72+
73+
while still having ``LIBGS`` set to the correct path, of course. If ``dvisvgm`` can find your Ghostscript installation, it will be shown in the output together with the version number.
74+
75+
If you do not have the necessary library on your system, please refer to your operating system's documentation in order to find out where you can get it and how you have to install it.
76+
77+
If you are unable to solve your problem, check out the `dvisvgm FAQ <https://dvisvgm.de/FAQ/>`_.

manim/utils/tex_file_writing.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,4 +205,14 @@ def convert_to_svg(dvi_file, extension, page=1):
205205
os.devnull,
206206
]
207207
os.system(" ".join(commands))
208+
209+
# if the file does not exist now, this means conversion failed
210+
if not os.path.exists(result):
211+
raise ValueError(
212+
f"Your installation does not support converting {extension} files to SVG."
213+
f" Consider updating dvisvgm to at least version 2.4."
214+
f" If this does not solve the problem, please refer to our troubleshooting guide at:"
215+
f" https://manimce.readthedocs.io/en/latest/installation/troubleshooting.html"
216+
)
217+
208218
return result

0 commit comments

Comments
 (0)