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

Solved svg2pdf conversion error if Inkscape is installed into the default path on a windows machine #1469

Merged
merged 2 commits into from
Jan 30, 2021

Conversation

MichaelAdolph
Copy link
Contributor

The " " in "Program Files" in the default path for Inkscape on a windows machine makes the conversion fail. I updated the file to enclose the command string into double quotes. This allows the system to run properly on windows.

I'm not able to test on a Mac or Linux/Unix machine, so I'm unsure if my solution will create problems for users on different operating systems.

Adolph added 2 commits November 19, 2020 11:55
…uble spaces. Unsure if this change impacts Linux or Mac Systems. But solves my problem on windows
@MichaelAdolph
Copy link
Contributor Author

The issues raises by the automated checks are part of the solution: The string isn't the same as expected because I added the double quotes. So failing the checks seems okay.

Still in question: how does this change impact other operating systems like Unix.

@MichaelAdolph MichaelAdolph changed the title [WIP] Solved svg2pdf conversion error if Inkscape is installed into the default path on a windows machine Solved svg2pdf conversion error if Inkscape is installed into the default path on a windows machine Dec 11, 2020
@ArgoHA
Copy link

ArgoHA commented Dec 25, 2020

hey there, I'm on mac os 11.1 and I am not able to export notebook to pdf (I have installed TeX)
Here is what I get on command "jupyter nbconvert wiam_test.ipynb --to pdf --output file.pdf"

[NbConvertApp] Converting notebook wiam_test.ipynb to pdf /bin/sh: inkscape: command not found Traceback (most recent call last): File "/Library/Frameworks/Python.framework/Versions/3.7/bin/jupyter-nbconvert", line 10, in <module> sys.exit(main()) File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/jupyter_core/application.py", line 270, in launch_instance return super(JupyterApp, cls).launch_instance(argv=argv, **kwargs) File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/traitlets/config/application.py", line 664, in launch_instance app.start() File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/nbconvert/nbconvertapp.py", line 340, in start self.convert_notebooks() File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/nbconvert/nbconvertapp.py", line 510, in convert_notebooks self.convert_single_notebook(notebook_filename) File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/nbconvert/nbconvertapp.py", line 481, in convert_single_notebook output, resources = self.export_single_notebook(notebook_filename, resources, input_buffer=input_buffer) File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/nbconvert/nbconvertapp.py", line 410, in export_single_notebook output, resources = self.exporter.from_filename(notebook_filename, resources=resources) File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/nbconvert/exporters/exporter.py", line 179, in from_filename return self.from_file(f, resources=resources, **kw) File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/nbconvert/exporters/exporter.py", line 197, in from_file return self.from_notebook_node(nbformat.read(file_stream, as_version=4), resources=resources, **kw) File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/nbconvert/exporters/pdf.py", line 171, in from_notebook_node nb, resources=resources, **kw File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/nbconvert/exporters/latex.py", line 88, in from_notebook_node return super(LatexExporter, self).from_notebook_node(nb, resources, **kw) File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/nbconvert/exporters/templateexporter.py", line 307, in from_notebook_node nb_copy, resources = super(TemplateExporter, self).from_notebook_node(nb, resources, **kw) File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/nbconvert/exporters/exporter.py", line 139, in from_notebook_node nb_copy, resources = self._preprocess(nb_copy, resources) File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/nbconvert/exporters/exporter.py", line 316, in _preprocess nbc, resc = preprocessor(nbc, resc) File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/nbconvert/preprocessors/base.py", line 47, in __call__ return self.preprocess(nb, resources) File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/nbconvert/preprocessors/base.py", line 69, in preprocess nb.cells[index], resources = self.preprocess_cell(cell, resources, index) File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/nbconvert/preprocessors/convertfigures.py", line 46, in preprocess_cell self.from_format, output.data[self.from_format]) File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/nbconvert/preprocessors/svg2pdf.py", line 110, in convert_figure raise TypeError("Inkscape svg to pdf conversion failed") TypeError: Inkscape svg to pdf conversion failed

@kjohnsen
Copy link

Thank you MichaelAdolph, I've had the same problem. Please work on getting this merged devs--for now I just edited the source code in my install.

Copy link
Contributor

@MSeal MSeal left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the fix -- apologies that not many devs have been active on this project recently

@MSeal MSeal merged commit 5852762 into jupyter:master Jan 30, 2021
@yuvipanda
Copy link
Contributor

I've fixed this and potentially other shell metacharacter issues with #1512.

@MichaelAdolph I'd love for you to test that out on windows!

MSeal pushed a commit that referenced this pull request Jun 7, 2021
* Don't use a shell to call inkscape

Python generally recommends against using `shell=True`
when calling
subprocesses (https://docs.python.org/3/library/subprocess.html#security-considerations).
This also causes issues with shell metacharacters (see
#1469). I'm also
not entirely sure that the shell command *is* fully trustable
- I don't know where {to_filename} and {from_filename} are
from. Rest of nbconvert also prefers using lists instead
of strings to call commands.

svg2pdf also uses a command instead of a string now. We leave
the old string implementation alone for backwards compatibility,
although I'd really prefer to remove it.

We don't need the quotes set up in
#1469,
since using a list automatically deals with that.

* Fix call to isinstance
@MSeal MSeal added this to the 6.1 milestone Jun 8, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants