Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

nbconvert failed: Inkscape svg to pdf conversion failed #769

Closed
JulieLen opened this issue Feb 26, 2018 · 15 comments
Closed

nbconvert failed: Inkscape svg to pdf conversion failed #769

JulieLen opened this issue Feb 26, 2018 · 15 comments

Comments

@JulieLen
Copy link

When I want to save my notebook as a PDF or Tex doc, I get this error message.
I have downloaded the Inkscape app on Mac, and the Inkscape extension, but it did not changed much.

I guess that somehow I need to tell Julia to take that "package" into account, but I don't know how.
Could someone provide guidance ?

Thanks !

@kylebarron
Copy link

Is there a file at:

/Applications/Inkscape.app/Contents/Resources/bin/inkscape

?

That's the location that nbconvert looks for on a Mac for the inkscape executable.

@t-makaro
Copy link
Contributor

This may be fixed by #985.

@t-makaro
Copy link
Contributor

t-makaro commented Aug 1, 2019

Closing issue as stale. If you'd like more information on similar issues see my comment here. If your issue is not fixed and does not fit into one of the other issues mentioned my comment, then please comment here asking to re-open and add any additional information that you may have.

@AshtonSBradley
Copy link

this is not fixed.

@MSeal
Copy link
Contributor

MSeal commented Jun 9, 2020

this is not fixed.

@AshtonSBradley Need some more details on this one for setup, steps taken, versions of packages used. Haven't had many reports of this issue in the year since this was released.

@AshtonSBradley
Copy link

sorry, that was not a very helpful comment of mine. I must admit I have given up trying to do any of this now, I just export to html and print the pdf. Does mean I can't get latex out of it anymore though.

Setup is MacOS 10.14.16, jupyterlab kernel is julia 1.4.

Error message is (for pdf and latex export):
nbconvert failed: Inkscape svg to pdf conversion failed

Not sure how to track down relevant packages that jupyter knows about.

higgs:~ abradley$ which inkscape
/usr/local/bin/inkscape

@MSeal
Copy link
Contributor

MSeal commented Jun 10, 2020

What version of nbconvert were you using (assuming 5.6.1)? And what version of inkscape? And finally what python version?

For a time, on OSX, it was installed in /Applications/Inkscape.app/Contents/Resources/bin/inkscape for pre 1.0 and /Applications/Inkscape.app/Contents/MacOS/inkscape for post 1.0. However we check which(inkscape) first if you're on python >= 3.3, which should find /usr/local/bin/inkscape. If you're on Python 2 it won't discover correct and we'll probably not backport the fix because it uses a Python 3 only package to achieve that.

@AshtonSBradley
Copy link

higgs:~ abradley$ jupyter --version
jupyter core : 4.6.1
jupyter-notebook : 6.0.2
qtconsole : not installed
ipython : 7.10.1
ipykernel : 5.1.3
jupyter client : 5.3.4
jupyter lab : 1.2.3
nbconvert : 5.6.1
ipywidgets : not installed
nbformat : 4.4.0
traitlets : 4.3.3

higgs:~ abradley$ inkscape --version
Inkscape 1.0 (4035a4f, 2020-05-01)
Pango version: 1.43.0

higgs:~ abradley$ python -V
Python 3.8.2

@MSeal
Copy link
Contributor

MSeal commented Jun 10, 2020

Can you paste the outcome of:

python -c "from shutil import which; print(which('inkscape'))" ? seems off that your command line can find the which patch but not nbconvert :/

@AshtonSBradley
Copy link

higgs:~ abradley$ python -c "from shutil import which; print(which('inkscape'))"
/usr/local/bin/inkscape

@MSeal
Copy link
Contributor

MSeal commented Jun 10, 2020

And you're running nbconvert from the same python installation? Are you setting any custom nbconvert / jupyter config anywhere?

Run this to check what the class has assigned at runtime for your environment: python -c "from nbconvert.preprocessors.svg2pdf import SVG2PDFPreprocessor; print(SVG2PDFPreprocessor().inkscape)"

@AshtonSBradley
Copy link

not sure, just running jupyter lab from the command line, installed with homebrew. I upgraded python (was 2 in command line), but that didn't fix it.

higgs:~ abradley$ python -c "from nbconvert.preprocessors.svg2pdf import SVG2PDFPreprocessor; print(SVG2PDFPreprocessor().inkscape)"
Traceback (most recent call last):
File "", line 1, in
ModuleNotFoundError: No module named 'nbconvert'

@MSeal
Copy link
Contributor

MSeal commented Jun 10, 2020

That means you're using a different python environment than your command line python because it doesn't have the dependency installed in the environment your command was using. This can happen on Mac OSX where your brew python, system python, and other python installations can get their sitepackage paths mixed up (I blame brew for this primarily because of how they install python relative to system python). I am guessing your jupyter lab installation is using python 2 and not python 3 (or an older version of nbconvert) which doesn't find the inkscape 1.0 path. If you do python -m pip install nbconvert I expect the path check call to work and the inkscape export command if you made it directly to nbconvert to also work.

The way to fix this more generally is to install a virtualenv or a conda environment to isolate your python packages and run lab while one of those are active. This helps eliminate the potential overlap in runtime python choices for packages / language versions.

@AshtonSBradley
Copy link

AshtonSBradley commented Jun 10, 2020

That didn't fix it.
I also reinstalled jupyter since upgrading python to 3. I used this method to upgrade via hombrew and pyenv
https://opensource.com/article/19/5/python-3-default-mac

btw I am not making any call to inkscape directly, just choosing export from jupyterlab.

Does jupyter use python 2 by default or something?

@MSeal
Copy link
Contributor

MSeal commented Jun 11, 2020

Does jupyter use python 2 by default or something?

No, you might need to check where you're jupyter command is stored and see how it's launching python ... maybe it's installed from your system python 2 and ignoring your local environment? (I don't have an OSX machine to inspect this for you). Normally these instructions do the trick (with jupyter lab instead of jupyter notebook for your case)

In the end I think you'd need to figure out what environment your jupyter lab is using and make sure it has nbconvert 5.6.1+ and is in python 3.5+.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants