I am trying to get the svg package working on an OSX system. If I use inkscape to save the *.svg files as *.pdf and *.pdf_tex, then the sample file from this question works fine:


  \caption{svg image}


But no matter what I try, the package will not create the pdf and pdf_tex files automatically. Instead I get an error:

! LaTeX Error: File `./example' not found.

I have added inkscape to the PATH. I've added the --shell-escape option to the latex command... I'm at a loss.

  • If the conversion is not successful, the necessary files won't be found. Try the manual conversion inkscape -z -C -f./example.svg -A./example.pdf --export-latex which may give some hints about what's going wrong. – egreg Dec 25 '15 at 23:37
  • Did you install it via dmg? You can check the installation dir with which inkscape. If this returns no answers, the problem is, that LaTeX can't find inkscape at all. – Rico Dec 26 '15 at 0:00
  • @egreg The command line does not work. ** (inkscape-bin:821): WARNING **: Can't open file: example.svg (doesn't exist). This looks to be related to a Mac python issue with directories. However, I've tried every combination on that webpage and nothing works. – weymouth Dec 26 '15 at 9:11
  • @Rico I installed via dmg, which I got from the website a few days ago. which inkscape gives /usr/local/bin/inkscape. Even if I run the command using the full path - I have the same issue. – weymouth Dec 26 '15 at 9:13
  • Maybe you could provide a screenshot of your folder structure. Could make it easier to figure out what is going wrong – Rico Dec 26 '15 at 10:37

This is a macOS-specific issue.

The inkscape shell script which invokes the main inkscape binary has to change directory to the inkscape installation directory, which is why it fails finding the SVG files in the current working directory.

See this explanatory comment on line 30 of the inkscape script, /usr/local/bin/inkscape on my macOS:

# Due to changes after 0.48, we have to change working directory in the script named 'inkscape':
# recursive calls to inkscape from python-based extensions otherwise cause the app to hang or
# fail (for python-based extensions, inkscape changes the working directory to the 
# script's directory, and inkscape launched by python script thus can't find resources
# like the now essential 'units.xml' in INKSCAPE_UIDIR relative to the working directory).
cd "$BASE" || exit 1

That's a smoking gun if I've ever seen one. :)

You can try commenting out the cd "$BASE" || exit 1 line, and the conversion should still work for simple SVGs. This is what I am currently doing.

Alternatively, one would have to modify svg LaTeX package to invoke inkscape with full input and output pathnames instead of relative. Another option would be to modify the inkscape shell script to expand relative paths to absolute.

| improve this answer | |
  • I'll try this out and hopefully give you a (long overdue) checkmark. – weymouth Feb 4 '19 at 13:51

Check that inkscape is in your PATH environment variable.

Test this by opening up your command terminal window and typing inkscape --version (do not do this in the directory you installed inkscape; we want to see if your environment can find the program from an arbitrary location, like your home directory)

If it returns with a version, then this is not your problem (sorry).

However, If it responds with any form of error, then the svg package won't be able to call inkscape to convert the file. For directions on adding inkscape to your PATH, see here (here for Windows).

Good luck!

| improve this answer | |
  • 1
    The poster already states the program is the PATH and shows an error message from the Inkscape saying it can't find the svg file. – Andrew Swann Jan 12 '17 at 7:17
  • 1
    Besides, the OP is on Mac OS X. – egreg Jan 12 '17 at 7:22
  • I've had similar errors on Linux and windows where the error shown was "cannot find file" when it was actually a path issue. So just suggesting this as a troubleshooting step to double check that it was added to PATH properly by running from console. (I've messed that up before). I'll amend the answer to add in editing path for Mac, missed that in the Q. Txs. – Jedidiah Bartlett Jan 12 '17 at 8:23

Try changing your command-line call to put --shell-escape first:

pdflatex --shell-escape -synctex=1 -interaction=nonstopmode example.tex

After having the \includesvg work and not work in Windows and Linux (ubuntu), and having this exact problem sometimes, but not others (however, after it stopped working, it seemed really hard to get it to compile again), I found that putting the --shell-escape option FIRST in the command line seems to make the pdflatex call work every time.

I hope this helps other people, I've been caught by this over and over again with no real rhyme or reason for why the pdflatex call starts failing.

Good luck! Let me know if this works for anyone else out there.

| improve this answer | |

My problem was the --clean option. I figured this out by selected pdflatex in TeXWorks and it suddenly built. Taking out options one by one helped me get to the bottom of this. Hope this helps someone (probably future me in six months).

| improve this answer | |
  • maybe you should mention that you are using latexmk, otherwise this answer might not make sense – user190633 Jun 11 '19 at 11:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.