Message Boards Message Boards


Calling an application Inkscape with RunProcess?

Posted 9 days ago
3 Replies
2 Total Likes

I am trying to emulate the command presented in this Stack Exchange question, about

...implement a way in Mathematica to export graphics to PDF and then use Inkscape from within Mathematica to post process the resulting output with the pdf-latex export option in Inkscape.

The code snippet is as follows:

Module[{fig, str = NotebookDirectory[]}, 
 fig = Plot[Cos[2 x], {x, 0, 2 Pi}, 
   AxesLabel -> {"$x$", "$\\cos{2x}$"}];
 Export[str <> "in.pdf", fig];
 RunProcess[{"inkscape", "-z", "-D", "--file=" <> str <> "in.pdf", 
   "--export-pdf=" <> str <> "out.pdf", "--export-latex"}, 
  ProcessEnvironment -> 
    DeleteCases[GetEnvironment[All], "LD_LIBRARY_PATH" -> _]]];]

But I get the following error when executing the command:

RunProcess: Program inkscape not found.  Check Environment["PATH"].

I tried also "/Applications/" as the path argument to RunProcess but the same error is printed.

I am running Mac OS 10.14.6, with Inkscape 1.0.0.

Can anyone indicate me with a correct path? Or am I missing something else about Inkscape here?

3 Replies

Hi Ehud,

Open the Terminal app and type

which inkscape
inkscape -V

If that works you need to make sure that the path returned by which is in the Mathematica PATH.

SetEnvironment["PATH" -> Environment["PATH"] <> ":" <> "path returned by which"]
Posted 9 days ago

Hmm.. Command not found.

But inkscape is installed on my computer!

Any idea? Sorry for being too novice.

Last time I used Inkscape was a few years ago on Ubuntu. Just installed the MacOS version. Command line interface from terminal

/Applications/ --help

So, add /Applications/ to the WL PATH as described in my earlier post and it should work.

Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
or Discard

Group Abstract Group Abstract