jupyter / nbconvert

Jupyter Notebook Conversion
https://nbconvert.readthedocs.io/
BSD 3-Clause "New" or "Revised" License
1.75k stars 569 forks source link

Conversion to pdf fails with SVG plots in 6.0.7 (5.6.1 is ok) #1447

Open magerton opened 4 years ago

magerton commented 4 years ago

After upgrading nbconvert from 5.6.1 to 6.0.7, I'm unable to convert a jupyter notebook to pdf when the notebook creates a plot using Julia's GR.jl. This seems like it's an issue w/ the conversion via Inkscape. My inkscape version is 0.92.4. Using the Julia Plots.jl pyplot (matplotlib) backend doesn't seem to create this issue. I also don't have this issue if I create a python notebook and use matplotlib to generate a pdf plot.

I don't believe that this is #1325 since my Inkscape directory does have spaces in it

Reproducing issue in python with matplotlib & svg output: python-mwe-no-issues.ipynb.txt

(base) PS E:\projects\are254-fall2020\assignments> jupyter nbconvert --debug --to=pdf .\python-mwe-no-issues.ipynb.txt
[NbConvertApp] Searching ['E:\\projects\\are254-fall2020\\assignments', 'C:\\Users\\magerton\\.jupyter', 'D:\\libraries\\julia\\conda\\3\\etc\\jupyter', 'C:\\ProgramData\\jupyter'] for config files
[NbConvertApp] Looking for jupyter_config in C:\ProgramData\jupyter
[NbConvertApp] Looking for jupyter_config in D:\libraries\julia\conda\3\etc\jupyter
[NbConvertApp] Looking for jupyter_config in C:\Users\magerton\.jupyter
[NbConvertApp] Looking for jupyter_config in E:\projects\are254-fall2020\assignments
[NbConvertApp] Looking for jupyter_nbconvert_config in C:\ProgramData\jupyter
[NbConvertApp] Looking for jupyter_nbconvert_config in D:\libraries\julia\conda\3\etc\jupyter
[NbConvertApp] Looking for jupyter_nbconvert_config in C:\Users\magerton\.jupyter
[NbConvertApp] Looking for jupyter_nbconvert_config in E:\projects\are254-fall2020\assignments
[NbConvertApp] Converting notebook .\python-mwe-no-issues.ipynb.txt to pdf
[NbConvertApp] Notebook name is 'python-mwe-no-issues.ipynb'
[NbConvertApp] Template paths:
        C:\Users\magerton\AppData\Roaming\jupyter\nbconvert\templates\latex
        D:\libraries\julia\conda\3\share\jupyter\nbconvert\templates\latex
        C:\ProgramData\jupyter\nbconvert\templates\latex
        C:\Users\magerton\AppData\Roaming\jupyter\nbconvert\templates\latex
        D:\libraries\julia\conda\3\share\jupyter\nbconvert\templates\latex
        C:\ProgramData\jupyter\nbconvert\templates\latex
        D:\libraries\julia\conda\3\share\jupyter\nbconvert\templates\base
        C:\Users\magerton\AppData\Roaming\jupyter
        C:\Users\magerton\AppData\Roaming\jupyter\nbconvert\templates
        C:\Users\magerton\AppData\Roaming\jupyter\nbconvert\templates\compatibility
        D:\libraries\julia\conda\3\share\jupyter
        D:\libraries\julia\conda\3\share\jupyter\nbconvert\templates
        D:\libraries\julia\conda\3\share\jupyter\nbconvert\templates\compatibility
        C:\ProgramData\jupyter
        C:\ProgramData\jupyter\nbconvert\templates
        C:\ProgramData\jupyter\nbconvert\templates\compatibility
[NbConvertApp] Applying preprocessor: TagRemovePreprocessor
[NbConvertApp] Applying preprocessor: RegexRemovePreprocessor
[NbConvertApp] Applying preprocessor: coalesce_streams
[NbConvertApp] Applying preprocessor: SVG2PDFPreprocessor
Traceback (most recent call last):
  File "D:\libraries\julia\conda\3\lib\site-packages\traitlets\traitlets.py", line 535, in get
    value = obj._trait_values[self.name]
KeyError: 'command'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "D:\libraries\julia\conda\3\lib\site-packages\traitlets\traitlets.py", line 535, in get
    value = obj._trait_values[self.name]
KeyError: 'inkscape_version'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "D:\libraries\julia\conda\3\Scripts\jupyter-nbconvert-script.py", line 10, in <module>
    sys.exit(main())
  File "D:\libraries\julia\conda\3\lib\site-packages\jupyter_core\application.py", line 270, in launch_instance
    return super(JupyterApp, cls).launch_instance(argv=argv, **kwargs)
  File "D:\libraries\julia\conda\3\lib\site-packages\traitlets\config\application.py", line 837, in launch_instance
    app.start()
  File "D:\libraries\julia\conda\3\lib\site-packages\nbconvert\nbconvertapp.py", line 350, in start
    self.convert_notebooks()
  File "D:\libraries\julia\conda\3\lib\site-packages\nbconvert\nbconvertapp.py", line 524, in convert_notebooks
    self.convert_single_notebook(notebook_filename)
  File "D:\libraries\julia\conda\3\lib\site-packages\nbconvert\nbconvertapp.py", line 489, in convert_single_notebook
    output, resources = self.export_single_notebook(notebook_filename, resources, input_buffer=input_buffer)
  File "D:\libraries\julia\conda\3\lib\site-packages\nbconvert\nbconvertapp.py", line 418, in export_single_notebook
    output, resources = self.exporter.from_filename(notebook_filename, resources=resources)
  File "D:\libraries\julia\conda\3\lib\site-packages\nbconvert\exporters\exporter.py", line 181, in from_filename
    return self.from_file(f, resources=resources, **kw)
  File "D:\libraries\julia\conda\3\lib\site-packages\nbconvert\exporters\exporter.py", line 199, in from_file
    return self.from_notebook_node(nbformat.read(file_stream, as_version=4), resources=resources, **kw)
  File "D:\libraries\julia\conda\3\lib\site-packages\nbconvert\exporters\pdf.py", line 168, in from_notebook_node
    latex, resources = super().from_notebook_node(
  File "D:\libraries\julia\conda\3\lib\site-packages\nbconvert\exporters\latex.py", line 77, in from_notebook_node
    return super().from_notebook_node(nb, resources, **kw)
  File "D:\libraries\julia\conda\3\lib\site-packages\nbconvert\exporters\templateexporter.py", line 369, in from_notebook_node
    nb_copy, resources = super().from_notebook_node(nb, resources, **kw)
  File "D:\libraries\julia\conda\3\lib\site-packages\nbconvert\exporters\exporter.py", line 143, in from_notebook_node
    nb_copy, resources = self._preprocess(nb_copy, resources)
  File "D:\libraries\julia\conda\3\lib\site-packages\nbconvert\exporters\exporter.py", line 318, in _preprocess
    nbc, resc = preprocessor(nbc, resc)
  File "D:\libraries\julia\conda\3\lib\site-packages\nbconvert\preprocessors\base.py", line 47, in __call__
    return self.preprocess(nb, resources)
  File "D:\libraries\julia\conda\3\lib\site-packages\nbconvert\preprocessors\base.py", line 69, in preprocess
    nb.cells[index], resources = self.preprocess_cell(cell, resources, index)
  File "D:\libraries\julia\conda\3\lib\site-packages\nbconvert\preprocessors\convertfigures.py", line 45, in preprocess_cell
    output.data[self.to_format] = self.convert_figure(
  File "D:\libraries\julia\conda\3\lib\site-packages\nbconvert\preprocessors\svg2pdf.py", line 125, in convert_figure
    shell = self.command.format(from_filename=input_filename,
  File "D:\libraries\julia\conda\3\lib\site-packages\traitlets\traitlets.py", line 575, in __get__
    return self.get(obj, cls)
  File "D:\libraries\julia\conda\3\lib\site-packages\traitlets\traitlets.py", line 538, in get
    default = obj.trait_defaults(self.name)
  File "D:\libraries\julia\conda\3\lib\site-packages\traitlets\traitlets.py", line 1577, in trait_defaults
    return self._get_trait_default_generator(names[0])(self)
  File "D:\libraries\julia\conda\3\lib\site-packages\traitlets\traitlets.py", line 975, in __call__
    return self.func(*args, **kwargs)
  File "D:\libraries\julia\conda\3\lib\site-packages\nbconvert\preprocessors\svg2pdf.py", line 77, in _command_default
    major_verison = self.inkscape_version.split('.')[0]
  File "D:\libraries\julia\conda\3\lib\site-packages\traitlets\traitlets.py", line 575, in __get__
    return self.get(obj, cls)
  File "D:\libraries\julia\conda\3\lib\site-packages\traitlets\traitlets.py", line 538, in get
    default = obj.trait_defaults(self.name)
  File "D:\libraries\julia\conda\3\lib\site-packages\traitlets\traitlets.py", line 1577, in trait_defaults
    return self._get_trait_default_generator(names[0])(self)
  File "D:\libraries\julia\conda\3\lib\site-packages\traitlets\traitlets.py", line 975, in __call__
    return self.func(*args, **kwargs)
  File "D:\libraries\julia\conda\3\lib\site-packages\nbconvert\preprocessors\svg2pdf.py", line 57, in _inkscape_version_default
    p = subprocess.Popen([self.inkscape, '--version'],
  File "D:\libraries\julia\conda\3\lib\subprocess.py", line 854, in __init__
    self._execute_child(args, executable, preexec_fn, close_fds,
  File "D:\libraries\julia\conda\3\lib\subprocess.py", line 1307, in _execute_child
    hp, ht, pid, tid = _winapi.CreateProcess(executable, args,
PermissionError: [WinError 5] Access is denied

Reproducing issue in Julia:

mwe.ipynb.txt

Nbconvert version: 6.0.7

(base) E:\projects\are254-fall2020\assignments>jupyter nbconvert --debug --to=pdf mwe.ipynb
[NbConvertApp] Searching ['E:\\projects\\are254-fall2020\\assignments', 'C:\\Users\\magerton\\.jupyter', 'D:\\libraries\\julia\\conda\\3\\etc\\jupyter', 'C:\\ProgramData\\jupyter'] for config files
[NbConvertApp] Looking for jupyter_config in C:\ProgramData\jupyter
[NbConvertApp] Looking for jupyter_config in D:\libraries\julia\conda\3\etc\jupyter
[NbConvertApp] Looking for jupyter_config in C:\Users\magerton\.jupyter
[NbConvertApp] Looking for jupyter_config in E:\projects\are254-fall2020\assignments
[NbConvertApp] Looking for jupyter_nbconvert_config in C:\ProgramData\jupyter
[NbConvertApp] Looking for jupyter_nbconvert_config in D:\libraries\julia\conda\3\etc\jupyter
[NbConvertApp] Looking for jupyter_nbconvert_config in C:\Users\magerton\.jupyter
[NbConvertApp] Looking for jupyter_nbconvert_config in E:\projects\are254-fall2020\assignments
[NbConvertApp] Converting notebook mwe.ipynb to pdf
[NbConvertApp] Notebook name is 'mwe'
[NbConvertApp] Template paths:
        C:\Users\magerton\AppData\Roaming\jupyter\nbconvert\templates\latex
        D:\libraries\julia\conda\3\share\jupyter\nbconvert\templates\latex
        C:\ProgramData\jupyter\nbconvert\templates\latex
        C:\Users\magerton\AppData\Roaming\jupyter\nbconvert\templates\latex
        D:\libraries\julia\conda\3\share\jupyter\nbconvert\templates\latex
        C:\ProgramData\jupyter\nbconvert\templates\latex
        D:\libraries\julia\conda\3\share\jupyter\nbconvert\templates\base
        C:\Users\magerton\AppData\Roaming\jupyter
        C:\Users\magerton\AppData\Roaming\jupyter\nbconvert\templates
        C:\Users\magerton\AppData\Roaming\jupyter\nbconvert\templates\compatibility
        D:\libraries\julia\conda\3\share\jupyter
        D:\libraries\julia\conda\3\share\jupyter\nbconvert\templates
        D:\libraries\julia\conda\3\share\jupyter\nbconvert\templates\compatibility
        C:\ProgramData\jupyter
        C:\ProgramData\jupyter\nbconvert\templates
        C:\ProgramData\jupyter\nbconvert\templates\compatibility
[NbConvertApp] Applying preprocessor: TagRemovePreprocessor
[NbConvertApp] Applying preprocessor: RegexRemovePreprocessor
[NbConvertApp] Applying preprocessor: coalesce_streams
[NbConvertApp] Applying preprocessor: SVG2PDFPreprocessor
Traceback (most recent call last):
  File "D:\libraries\julia\conda\3\lib\site-packages\traitlets\traitlets.py", line 535, in get
    value = obj._trait_values[self.name]
KeyError: 'command'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "D:\libraries\julia\conda\3\lib\site-packages\traitlets\traitlets.py", line 535, in get
    value = obj._trait_values[self.name]
KeyError: 'inkscape_version'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "D:\libraries\julia\conda\3\Scripts\jupyter-nbconvert-script.py", line 10, in <module>
    sys.exit(main())
  File "D:\libraries\julia\conda\3\lib\site-packages\jupyter_core\application.py", line 270, in launch_instance
    return super(JupyterApp, cls).launch_instance(argv=argv, **kwargs)
  File "D:\libraries\julia\conda\3\lib\site-packages\traitlets\config\application.py", line 837, in launch_instance
    app.start()
  File "D:\libraries\julia\conda\3\lib\site-packages\nbconvert\nbconvertapp.py", line 350, in start
    self.convert_notebooks()
  File "D:\libraries\julia\conda\3\lib\site-packages\nbconvert\nbconvertapp.py", line 524, in convert_notebooks
    self.convert_single_notebook(notebook_filename)
  File "D:\libraries\julia\conda\3\lib\site-packages\nbconvert\nbconvertapp.py", line 489, in convert_single_notebook
    output, resources = self.export_single_notebook(notebook_filename, resources, input_buffer=input_buffer)
  File "D:\libraries\julia\conda\3\lib\site-packages\nbconvert\nbconvertapp.py", line 418, in export_single_notebook
    output, resources = self.exporter.from_filename(notebook_filename, resources=resources)
  File "D:\libraries\julia\conda\3\lib\site-packages\nbconvert\exporters\exporter.py", line 181, in from_filename
    return self.from_file(f, resources=resources, **kw)
  File "D:\libraries\julia\conda\3\lib\site-packages\nbconvert\exporters\exporter.py", line 199, in from_file
    return self.from_notebook_node(nbformat.read(file_stream, as_version=4), resources=resources, **kw)
  File "D:\libraries\julia\conda\3\lib\site-packages\nbconvert\exporters\pdf.py", line 168, in from_notebook_node
    latex, resources = super().from_notebook_node(
  File "D:\libraries\julia\conda\3\lib\site-packages\nbconvert\exporters\latex.py", line 77, in from_notebook_node
    return super().from_notebook_node(nb, resources, **kw)
  File "D:\libraries\julia\conda\3\lib\site-packages\nbconvert\exporters\templateexporter.py", line 369, in from_notebook_node
    nb_copy, resources = super().from_notebook_node(nb, resources, **kw)
  File "D:\libraries\julia\conda\3\lib\site-packages\nbconvert\exporters\exporter.py", line 143, in from_notebook_node
    nb_copy, resources = self._preprocess(nb_copy, resources)
  File "D:\libraries\julia\conda\3\lib\site-packages\nbconvert\exporters\exporter.py", line 318, in _preprocess
    nbc, resc = preprocessor(nbc, resc)
  File "D:\libraries\julia\conda\3\lib\site-packages\nbconvert\preprocessors\base.py", line 47, in __call__
    return self.preprocess(nb, resources)
  File "D:\libraries\julia\conda\3\lib\site-packages\nbconvert\preprocessors\base.py", line 69, in preprocess
    nb.cells[index], resources = self.preprocess_cell(cell, resources, index)
  File "D:\libraries\julia\conda\3\lib\site-packages\nbconvert\preprocessors\convertfigures.py", line 45, in preprocess_cell
    output.data[self.to_format] = self.convert_figure(
  File "D:\libraries\julia\conda\3\lib\site-packages\nbconvert\preprocessors\svg2pdf.py", line 125, in convert_figure
    shell = self.command.format(from_filename=input_filename,
  File "D:\libraries\julia\conda\3\lib\site-packages\traitlets\traitlets.py", line 575, in __get__
    return self.get(obj, cls)
  File "D:\libraries\julia\conda\3\lib\site-packages\traitlets\traitlets.py", line 538, in get
    default = obj.trait_defaults(self.name)
  File "D:\libraries\julia\conda\3\lib\site-packages\traitlets\traitlets.py", line 1577, in trait_defaults
    return self._get_trait_default_generator(names[0])(self)
  File "D:\libraries\julia\conda\3\lib\site-packages\traitlets\traitlets.py", line 975, in __call__
    return self.func(*args, **kwargs)
  File "D:\libraries\julia\conda\3\lib\site-packages\nbconvert\preprocessors\svg2pdf.py", line 77, in _command_default
    major_verison = self.inkscape_version.split('.')[0]
  File "D:\libraries\julia\conda\3\lib\site-packages\traitlets\traitlets.py", line 575, in __get__
    return self.get(obj, cls)
  File "D:\libraries\julia\conda\3\lib\site-packages\traitlets\traitlets.py", line 538, in get
    default = obj.trait_defaults(self.name)
  File "D:\libraries\julia\conda\3\lib\site-packages\traitlets\traitlets.py", line 1577, in trait_defaults
    return self._get_trait_default_generator(names[0])(self)
  File "D:\libraries\julia\conda\3\lib\site-packages\traitlets\traitlets.py", line 975, in __call__
    return self.func(*args, **kwargs)
  File "D:\libraries\julia\conda\3\lib\site-packages\nbconvert\preprocessors\svg2pdf.py", line 57, in _inkscape_version_default
    p = subprocess.Popen([self.inkscape, '--version'],
  File "D:\libraries\julia\conda\3\lib\subprocess.py", line 854, in __init__
    self._execute_child(args, executable, preexec_fn, close_fds,
  File "D:\libraries\julia\conda\3\lib\subprocess.py", line 1307, in _execute_child
    hp, ht, pid, tid = _winapi.CreateProcess(executable, args,
PermissionError: [WinError 5] Access is denied

Conda environment that fails

(base) E:\projects\are254-fall2020\assignments>conda list
# packages in environment at D:\libraries\julia\conda\3:
#
# Name                    Version                   Build  Channel
argon2-cffi               20.1.0           py38he774522_1
async_generator           1.10                       py_0
attrs                     20.2.0                     py_0
backcall                  0.2.0                      py_0
blas                      1.0                         mkl
bleach                    3.2.1                      py_0
brotlipy                  0.7.0           py38he774522_1000
ca-certificates           2020.6.20            hecda079_0    conda-forge
certifi                   2020.6.20        py38h9bdc248_2    conda-forge
cffi                      1.14.3           py38h7a1dbc1_0
chardet                   3.0.4                 py38_1003
colorama                  0.4.3                      py_0
conda                     4.8.5            py38h9bdc248_2    conda-forge
conda-package-handling    1.6.1            py38h62dcd97_0
console_shortcut          0.1.1                         4
cryptography              3.1.1            py38h7a1dbc1_0
cycler                    0.10.0                   py38_0
decorator                 4.4.2                      py_0
defusedxml                0.6.0                      py_0
entrypoints               0.3                      py38_0
freetype                  2.10.2               hd328e21_0
icu                       58.2                 ha925a31_3
idna                      2.10                       py_0
importlib-metadata        1.7.0                    py38_0
importlib_metadata        1.7.0                         0
intel-openmp              2020.2                      254
ipykernel                 5.3.4            py38h5ca1d4c_0
ipython                   7.18.1           py38h5ca1d4c_0
ipython_genutils          0.2.0                    py38_0
jedi                      0.15.2                   py38_0    conda-forge
jinja2                    2.11.2                     py_0
jpeg                      9b                   hb83a4c4_2
json5                     0.9.5                      py_0
jsonschema                3.2.0                    py38_1
jupyter_client            6.1.7                      py_0
jupyter_core              4.6.3                    py38_0
jupyterlab                2.2.6                      py_0
jupyterlab_pygments       0.1.2                      py_0
jupyterlab_server         1.2.0                      py_0
kiwisolver                1.2.0            py38h74a9793_0
libpng                    1.6.37               h2a8f88b_0
libsodium                 1.0.18               h62dcd97_0
libtiff                   4.1.0                h56a325e_1
lz4-c                     1.9.2                hf4a77e7_3
m2w64-gcc-libgfortran     5.3.0                         6
m2w64-gcc-libs            5.3.0                         7
m2w64-gcc-libs-core       5.3.0                         7
m2w64-gmp                 6.1.0                         2
m2w64-libwinpthread-git   5.0.0.4634.697f757               2
markupsafe                1.1.1            py38he774522_0
matplotlib                3.3.1                         0
matplotlib-base           3.3.1            py38hba9282a_0
menuinst                  1.4.16           py38he774522_1
mistune                   0.8.4           py38he774522_1000
mkl                       2020.2                      256
mkl-service               2.3.0            py38hb782905_0
mkl_fft                   1.2.0            py38h45dec08_0
mkl_random                1.1.1            py38h47e9c7a_0
msys2-conda-epoch         20160418                      1
nbclient                  0.5.0                      py_0
nbconvert                 6.0.7            py38h32f6830_0    conda-forge
nbformat                  5.0.7                      py_0
nest-asyncio              1.4.1                      py_0
nodejs                    10.13.0                       0
notebook                  6.1.4                    py38_0
numpy                     1.19.1           py38h5510c5b_0
numpy-base                1.19.1           py38ha3acd2a_0
olefile                   0.46                       py_0
openssl                   1.1.1h               he774522_0    conda-forge
packaging                 20.4                       py_0
pandoc                    2.10.1                        0
pandocfilters             1.4.2                    py38_1
parso                     0.8.0                      py_0
pickleshare               0.7.5                 py38_1000
pillow                    7.2.0            py38hcc1f983_0
pip                       20.2.3                   py38_0
powershell_shortcut       0.0.1                         3
prometheus_client         0.8.0                      py_0
prompt-toolkit            3.0.7                      py_0
pycosat                   0.6.3            py38he774522_0
pycparser                 2.20                       py_2
pygments                  2.7.1                      py_0
pyopenssl                 19.1.0                     py_1
pyparsing                 2.4.7                      py_0
pyqt                      5.9.2            py38ha925a31_4
pyrsistent                0.17.3           py38he774522_0
pysocks                   1.7.1                    py38_0
python                    3.8.5                h5fd99cc_1
python-dateutil           2.8.1                      py_0
python_abi                3.8                      1_cp38    conda-forge
pywin32                   227              py38he774522_1
pywinpty                  0.5.7                    py38_0
pyzmq                     19.0.2           py38ha925a31_1
qt                        5.9.7            vc14h73c81de_0
requests                  2.24.0                     py_0
ruamel_yaml               0.15.87          py38he774522_1
send2trash                1.5.0                    py38_0
setuptools                50.3.0           py38h9490d1a_1
sip                       4.19.13          py38ha925a31_0
six                       1.15.0                     py_0
sqlite                    3.33.0               h2a8f88b_0
terminado                 0.8.3                    py38_0
testpath                  0.4.4                      py_0
tk                        8.6.10               he774522_0
tornado                   6.0.4            py38he774522_1
tqdm                      4.50.2                     py_0
traitlets                 5.0.4                      py_0
urllib3                   1.25.10                    py_0
vc                        14.1                 h0510ff6_4
vs2015_runtime            14.16.27012          hf0eaf9b_3
wcwidth                   0.2.5                      py_0
webencodings              0.5.1                    py38_1
wheel                     0.35.1                     py_0
win_inet_pton             1.1.0                    py38_0
wincertstore              0.2                      py38_0
winpty                    0.4.3                         4
xz                        5.2.5                h62dcd97_0
yaml                      0.2.5                he774522_0
zeromq                    4.3.2                ha925a31_3
zipp                      3.3.0                      py_0
zlib                      1.2.11               h62dcd97_4
zstd                      1.4.5                h04227a9_0

Conda environment that works

(base) E:\projects\are254-fall2020\assignments>conda list
# packages in environment at D:\libraries\julia\conda\3:
#
# Name                    Version                   Build  Channel
argon2-cffi               20.1.0           py38he774522_1
async_generator           1.10                       py_0
attrs                     20.2.0                     py_0
backcall                  0.2.0                      py_0
blas                      1.0                         mkl
bleach                    3.2.1                      py_0
brotlipy                  0.7.0           py38he774522_1000
ca-certificates           2020.6.20            hecda079_0    conda-forge
certifi                   2020.6.20        py38h9bdc248_2    conda-forge
cffi                      1.14.3           py38h7a1dbc1_0
chardet                   3.0.4                 py38_1003
colorama                  0.4.3                      py_0
conda                     4.8.5            py38h9bdc248_2    conda-forge
conda-package-handling    1.6.1            py38h62dcd97_0
console_shortcut          0.1.1                         4
cryptography              3.1.1            py38h7a1dbc1_0
cycler                    0.10.0                   py38_0
decorator                 4.4.2                      py_0
defusedxml                0.6.0                      py_0
entrypoints               0.3                      py38_0
freetype                  2.10.2               hd328e21_0
icu                       58.2                 ha925a31_3
idna                      2.10                       py_0
importlib-metadata        1.7.0                    py38_0
importlib_metadata        1.7.0                         0
intel-openmp              2020.2                      254
ipykernel                 5.3.4            py38h5ca1d4c_0
ipython                   7.18.1           py38h5ca1d4c_0
ipython_genutils          0.2.0                    py38_0
jedi                      0.15.2                   py38_0    conda-forge
jinja2                    2.11.2                     py_0
jpeg                      9b                   hb83a4c4_2
json5                     0.9.5                      py_0
jsonschema                3.2.0                    py38_1
jupyter_client            6.1.7                      py_0
jupyter_core              4.6.3                    py38_0
jupyterlab                2.2.6                      py_0
jupyterlab_pygments       0.1.2                      py_0
jupyterlab_server         1.2.0                      py_0
kiwisolver                1.2.0            py38h74a9793_0
libpng                    1.6.37               h2a8f88b_0
libsodium                 1.0.18               h62dcd97_0
libtiff                   4.1.0                h56a325e_1
lz4-c                     1.9.2                hf4a77e7_3
m2w64-gcc-libgfortran     5.3.0                         6
m2w64-gcc-libs            5.3.0                         7
m2w64-gcc-libs-core       5.3.0                         7
m2w64-gmp                 6.1.0                         2
m2w64-libwinpthread-git   5.0.0.4634.697f757               2
markupsafe                1.1.1            py38he774522_0
matplotlib                3.3.1                         0
matplotlib-base           3.3.1            py38hba9282a_0
menuinst                  1.4.16           py38he774522_1
mistune                   0.8.4           py38he774522_1000
mkl                       2020.2                      256
mkl-service               2.3.0            py38hb782905_0
mkl_fft                   1.2.0            py38h45dec08_0
mkl_random                1.1.1            py38h47e9c7a_0
msys2-conda-epoch         20160418                      1
nbclient                  0.5.0                      py_0
nbconvert                 5.6.1                    py38_0
nbformat                  5.0.7                      py_0
nest-asyncio              1.4.1                      py_0
nodejs                    10.13.0                       0
notebook                  6.1.4                    py38_0
numpy                     1.19.1           py38h5510c5b_0
numpy-base                1.19.1           py38ha3acd2a_0
olefile                   0.46                       py_0
openssl                   1.1.1h               he774522_0    conda-forge
packaging                 20.4                       py_0
pandoc                    2.10.1                        0
pandocfilters             1.4.2                    py38_1
parso                     0.8.0                      py_0
pickleshare               0.7.5                 py38_1000
pillow                    7.2.0            py38hcc1f983_0
pip                       20.2.3                   py38_0
powershell_shortcut       0.0.1                         3
prometheus_client         0.8.0                      py_0
prompt-toolkit            3.0.7                      py_0
pycosat                   0.6.3            py38he774522_0
pycparser                 2.20                       py_2
pygments                  2.7.1                      py_0
pyopenssl                 19.1.0                     py_1
pyparsing                 2.4.7                      py_0
pyqt                      5.9.2            py38ha925a31_4
pyrsistent                0.17.3           py38he774522_0
pysocks                   1.7.1                    py38_0
python                    3.8.5                h5fd99cc_1
python-dateutil           2.8.1                      py_0
python_abi                3.8                      1_cp38    conda-forge
pywin32                   227              py38he774522_1
pywinpty                  0.5.7                    py38_0
pyzmq                     19.0.2           py38ha925a31_1
qt                        5.9.7            vc14h73c81de_0
requests                  2.24.0                     py_0
ruamel_yaml               0.15.87          py38he774522_1
send2trash                1.5.0                    py38_0
setuptools                50.3.0           py38h9490d1a_1
sip                       4.19.13          py38ha925a31_0
six                       1.15.0                     py_0
sqlite                    3.33.0               h2a8f88b_0
terminado                 0.8.3                    py38_0
testpath                  0.4.4                      py_0
tk                        8.6.10               he774522_0
tornado                   6.0.4            py38he774522_1
tqdm                      4.50.2                     py_0
traitlets                 5.0.4                      py_0
urllib3                   1.25.10                    py_0
vc                        14.1                 h0510ff6_4
vs2015_runtime            14.16.27012          hf0eaf9b_3
wcwidth                   0.2.5                      py_0
webencodings              0.5.1                    py38_1
wheel                     0.35.1                     py_0
win_inet_pton             1.1.0                    py38_0
wincertstore              0.2                      py38_0
winpty                    0.4.3                         4
xz                        5.2.5                h62dcd97_0
yaml                      0.2.5                he774522_0
zeromq                    4.3.2                ha925a31_3
zipp                      3.3.0                      py_0
zlib                      1.2.11               h62dcd97_4
zstd                      1.4.5                h04227a9_0

Julia version info

julia> versioninfo()
Julia Version 1.5.2
Commit 539f3ce943 (2020-09-23 23:17 UTC)
Platform Info:
  OS: Windows (x86_64-w64-mingw32)
  CPU: Intel(R) Xeon(R) W-2145 CPU @ 3.70GHz
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-9.0.1 (ORCJIT, skylake-avx512)
Environment:
  JULIA_DEPOT_PATH = D:\libraries\julia
  JULIA_NUM_THREADS = 8
  JULIA_PKGDIR = D:\libraries\julia
  JULIA_PKG_DEVDIR = D:\libraries\julia\dev

(@v1.5) pkg> status
Status `D:\libraries\julia\environments\v1.5\Project.toml`
  [28f2ccd6] ApproxFun v0.12.2
  [c52e3926] Atom v0.12.24
  [08854c51] BasisMatrices v0.7.0
  [6e4b80f9] BenchmarkTools v0.5.0
  [49dc2e85] Calculus v0.5.1
  [8f4d0f93] Conda v1.4.1
  [a93c6f00] DataFrames v0.21.7
  [39dd38d3] Dierckx v0.5.0
  [31c24e10] Distributions v0.23.12
  [442a2c76] FastGaussQuadrature v0.4.3
  [f6369f11] ForwardDiff v0.10.12
  [28b8d3ca] GR v0.52.0
  [7073ff75] IJulia v1.21.4
  [a98d9a8b] Interpolations v0.12.10
  [42fd0dbc] IterativeSolvers v0.8.4
  [e5e0dc1b] Juno v0.8.4
  [76087f3c] NLopt v0.6.0
  [2774e3e8] NLsolve v4.4.1
  [429524aa] Optim v1.2.0
  [91a5bcdd] Plots v1.6.9
  [438e738f] PyCall v1.92.1
  [d330b81b] PyPlot v2.9.0
  [1fd47b50] QuadGK v2.4.1
  [fcd29c91] QuantEcon v0.16.2
  [f2b01f46] Roots v1.0.5
  [2913bbd2] StatsBase v0.33.1
  [4c63d2b9] StatsFuns v0.9.5
  [0f1e0344] WebIO v0.8.14
  [b77e0a4c] InteractiveUtils
  [37e2e46d] LinearAlgebra
  [9a3f8284] Random
  [8dfed614] Test
magerton commented 4 years ago

Here are the explicit python environments

environment-works.txt environment-fails.txt

MSeal commented 4 years ago

That's probably unrelated to Julia, looks like the Inkscape path that was found is pointing to an executable that needs admin privilages to use. 6.0 has a different code path for finding inkscape that can search your registry instead of looking in fixed paths. I can't reproduce this easily on my machine, so you likely need to modify nbconvert to print what the self.inkscape value is in svg2pdf.py and tracing that path to figure out why permissions are such on that executable.

magerton commented 4 years ago

I'm not very good with python, and so not sure exactly how to have things print (adding a simple print statement didn't do the trick.... but I may have been modifying the wrong file). However, the registry value script gets to is just the executable: "C:\Program Files\Inkscape\inkscape.exe". FWIW, installing requires admin permissions (and my account isn't an admin account).

MSeal commented 4 years ago

Can you try running the nbconvert call as an admin? It sounds like it simply can't call "C:\Program Files\Inkscape\inkscape.exe". If that's the case maybe look into opening up permissions for that executable to be used by your account.

magerton commented 4 years ago

Just ran the script as admin, and I get the same error.

(base) PS E:\projects\are254-fall2020\assignments> jupyter nbconvert --debug --to=pdf .\python-mwe-no-issues.ipynb.txt
[NbConvertApp] Searching ['E:\\projects\\are254-fall2020\\assignments', 'C:\\Users\\mjaadmin\\.jupyter', 'D:\\libraries\\julia\\conda\\3\\etc\\jupyter', 'C:\\ProgramData\\jupyter'] for config files
[NbConvertApp] Looking for jupyter_config in C:\ProgramData\jupyter
[NbConvertApp] Looking for jupyter_config in D:\libraries\julia\conda\3\etc\jupyter
[NbConvertApp] Looking for jupyter_config in C:\Users\mjaadmin\.jupyter
[NbConvertApp] Looking for jupyter_config in E:\projects\are254-fall2020\assignments
[NbConvertApp] Looking for jupyter_nbconvert_config in C:\ProgramData\jupyter
[NbConvertApp] Looking for jupyter_nbconvert_config in D:\libraries\julia\conda\3\etc\jupyter
[NbConvertApp] Looking for jupyter_nbconvert_config in C:\Users\mjaadmin\.jupyter
[NbConvertApp] Looking for jupyter_nbconvert_config in E:\projects\are254-fall2020\assignments
[NbConvertApp] Converting notebook .\python-mwe-no-issues.ipynb.txt to pdf
[NbConvertApp] Notebook name is 'python-mwe-no-issues.ipynb'
[NbConvertApp] Template paths:
        C:\Users\mjaadmin\AppData\Roaming\jupyter\nbconvert\templates\latex
        D:\libraries\julia\conda\3\share\jupyter\nbconvert\templates\latex
        C:\ProgramData\jupyter\nbconvert\templates\latex
        C:\Users\mjaadmin\AppData\Roaming\jupyter\nbconvert\templates\latex
        D:\libraries\julia\conda\3\share\jupyter\nbconvert\templates\latex
        C:\ProgramData\jupyter\nbconvert\templates\latex
        D:\libraries\julia\conda\3\share\jupyter\nbconvert\templates\base
        C:\Users\mjaadmin\AppData\Roaming\jupyter
        C:\Users\mjaadmin\AppData\Roaming\jupyter\nbconvert\templates
        C:\Users\mjaadmin\AppData\Roaming\jupyter\nbconvert\templates\compatibility
        D:\libraries\julia\conda\3\share\jupyter
        D:\libraries\julia\conda\3\share\jupyter\nbconvert\templates
        D:\libraries\julia\conda\3\share\jupyter\nbconvert\templates\compatibility
        C:\ProgramData\jupyter
        C:\ProgramData\jupyter\nbconvert\templates
        C:\ProgramData\jupyter\nbconvert\templates\compatibility
[NbConvertApp] Applying preprocessor: TagRemovePreprocessor
[NbConvertApp] Applying preprocessor: RegexRemovePreprocessor
[NbConvertApp] Applying preprocessor: coalesce_streams
[NbConvertApp] Applying preprocessor: SVG2PDFPreprocessor
Traceback (most recent call last):
  File "D:\libraries\julia\conda\3\lib\site-packages\traitlets\traitlets.py", line 535, in get
    value = obj._trait_values[self.name]
KeyError: 'command'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "D:\libraries\julia\conda\3\lib\site-packages\traitlets\traitlets.py", line 535, in get
    value = obj._trait_values[self.name]
KeyError: 'inkscape_version'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "D:\libraries\julia\conda\3\Scripts\jupyter-nbconvert-script.py", line 10, in <module>
    sys.exit(main())
  File "D:\libraries\julia\conda\3\lib\site-packages\jupyter_core\application.py", line 270, in launch_instance
    return super(JupyterApp, cls).launch_instance(argv=argv, **kwargs)
  File "D:\libraries\julia\conda\3\lib\site-packages\traitlets\config\application.py", line 837, in launch_instance
    app.start()
  File "D:\libraries\julia\conda\3\lib\site-packages\nbconvert\nbconvertapp.py", line 350, in start
    self.convert_notebooks()
  File "D:\libraries\julia\conda\3\lib\site-packages\nbconvert\nbconvertapp.py", line 524, in convert_notebooks
    self.convert_single_notebook(notebook_filename)
  File "D:\libraries\julia\conda\3\lib\site-packages\nbconvert\nbconvertapp.py", line 489, in convert_single_notebook
    output, resources = self.export_single_notebook(notebook_filename, resources, input_buffer=input_buffer)
  File "D:\libraries\julia\conda\3\lib\site-packages\nbconvert\nbconvertapp.py", line 418, in export_single_notebook
    output, resources = self.exporter.from_filename(notebook_filename, resources=resources)
  File "D:\libraries\julia\conda\3\lib\site-packages\nbconvert\exporters\exporter.py", line 181, in from_filename
    return self.from_file(f, resources=resources, **kw)
  File "D:\libraries\julia\conda\3\lib\site-packages\nbconvert\exporters\exporter.py", line 199, in from_file
    return self.from_notebook_node(nbformat.read(file_stream, as_version=4), resources=resources, **kw)
  File "D:\libraries\julia\conda\3\lib\site-packages\nbconvert\exporters\pdf.py", line 168, in from_notebook_node
    latex, resources = super().from_notebook_node(
  File "D:\libraries\julia\conda\3\lib\site-packages\nbconvert\exporters\latex.py", line 77, in from_notebook_node
    return super().from_notebook_node(nb, resources, **kw)
  File "D:\libraries\julia\conda\3\lib\site-packages\nbconvert\exporters\templateexporter.py", line 369, in from_notebook_node
    nb_copy, resources = super().from_notebook_node(nb, resources, **kw)
  File "D:\libraries\julia\conda\3\lib\site-packages\nbconvert\exporters\exporter.py", line 143, in from_notebook_node
    nb_copy, resources = self._preprocess(nb_copy, resources)
  File "D:\libraries\julia\conda\3\lib\site-packages\nbconvert\exporters\exporter.py", line 318, in _preprocess
    nbc, resc = preprocessor(nbc, resc)
  File "D:\libraries\julia\conda\3\lib\site-packages\nbconvert\preprocessors\base.py", line 47, in __call__
    return self.preprocess(nb, resources)
  File "D:\libraries\julia\conda\3\lib\site-packages\nbconvert\preprocessors\base.py", line 69, in preprocess
    nb.cells[index], resources = self.preprocess_cell(cell, resources, index)
  File "D:\libraries\julia\conda\3\lib\site-packages\nbconvert\preprocessors\convertfigures.py", line 45, in preprocess_cell
    output.data[self.to_format] = self.convert_figure(
  File "D:\libraries\julia\conda\3\lib\site-packages\nbconvert\preprocessors\svg2pdf.py", line 125, in convert_figure
    shell = self.command.format(from_filename=input_filename,
  File "D:\libraries\julia\conda\3\lib\site-packages\traitlets\traitlets.py", line 575, in __get__
    return self.get(obj, cls)
  File "D:\libraries\julia\conda\3\lib\site-packages\traitlets\traitlets.py", line 538, in get
    default = obj.trait_defaults(self.name)
  File "D:\libraries\julia\conda\3\lib\site-packages\traitlets\traitlets.py", line 1577, in trait_defaults
    return self._get_trait_default_generator(names[0])(self)
  File "D:\libraries\julia\conda\3\lib\site-packages\traitlets\traitlets.py", line 975, in __call__
    return self.func(*args, **kwargs)
  File "D:\libraries\julia\conda\3\lib\site-packages\nbconvert\preprocessors\svg2pdf.py", line 77, in _command_default
    major_verison = self.inkscape_version.split('.')[0]
  File "D:\libraries\julia\conda\3\lib\site-packages\traitlets\traitlets.py", line 575, in __get__
    return self.get(obj, cls)
  File "D:\libraries\julia\conda\3\lib\site-packages\traitlets\traitlets.py", line 538, in get
    default = obj.trait_defaults(self.name)
  File "D:\libraries\julia\conda\3\lib\site-packages\traitlets\traitlets.py", line 1577, in trait_defaults
    return self._get_trait_default_generator(names[0])(self)
  File "D:\libraries\julia\conda\3\lib\site-packages\traitlets\traitlets.py", line 975, in __call__
    return self.func(*args, **kwargs)
  File "D:\libraries\julia\conda\3\lib\site-packages\nbconvert\preprocessors\svg2pdf.py", line 57, in _inkscape_version_default
    p = subprocess.Popen([self.inkscape, '--version'],
  File "D:\libraries\julia\conda\3\lib\subprocess.py", line 854, in __init__
    self._execute_child(args, executable, preexec_fn, close_fds,
  File "D:\libraries\julia\conda\3\lib\subprocess.py", line 1307, in _execute_child
    hp, ht, pid, tid = _winapi.CreateProcess(executable, args,
PermissionError: [WinError 5] Access is denied
magerton commented 4 years ago

@MSeal, here's an even smaller MWE that works when run from a simple python terminal. It looks like things blow up when the inkscape version gets requested from the shell. I've tried tinkering w/ the code in the Conda package to see if I could further diagnose, but I'm actually not sure that I'm editing the right file and getting python to see it... I wish I could be of more help!

I'll note that getting the Inkscape version from the command line requires that I execute the .com file, not the .exe. See output from Cmd.exe below.

C:\Users\magerton>"C:\Program Files\Inkscape\inkscape.com" --version
Inkscape 0.92.4 (5da689c313, 2019-01-14)

C:\Users\magerton>"C:\Program Files\Inkscape\inkscape.exe" --version

C:\Users\magerton>
from nbconvert import preprocessors

x = preprocessors.SVG2PDFPreprocessor()

# adobe SVG
SVG_STR = "<svg viewBox='0 0 105 93' xmlns='http://www.w3.org/2000/svg'>\n<path d='M66,0h39v93zM38,0h-38v93zM52,35l25,58h-16l-8-18h-18z' fill='#ED1C24'/>\n</svg>\n"

x.inkscape

x.inkscape_version() # fails here

# not run
# x.convert_figure('svg', SVG_STR)
>>> from nbconvert import preprocessors
>>>
>>> x = preprocessors.SVG2PDFPreprocessor()
>>>
>>> # adobe SVG
>>> SVG_STR = "<svg viewBox='0 0 105 93' xmlns='http://www.w3.org/2000/svg'>\n<path d='M66,0h39v93zM38,0h-38v93zM52,35l25,58h-16l-8-18h-18z' fill='#ED1C24'/>\n</svg>\n"
>>>
>>> x.inkscape
'"C:\\Program Files\\Inkscape\\inkscape.exe"'
>>>
>>> x.inkscape_version() # fails here
Traceback (most recent call last):
  File "D:\libraries\julia\conda\3\lib\site-packages\traitlets\traitlets.py", line 535, in get
    value = obj._trait_values[self.name]
KeyError: 'inkscape_version'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "D:\libraries\julia\conda\3\lib\site-packages\traitlets\traitlets.py", line 575, in __get__
    return self.get(obj, cls)
  File "D:\libraries\julia\conda\3\lib\site-packages\traitlets\traitlets.py", line 538, in get
    default = obj.trait_defaults(self.name)
  File "D:\libraries\julia\conda\3\lib\site-packages\traitlets\traitlets.py", line 1577, in trait_defaults
    return self._get_trait_default_generator(names[0])(self)
  File "D:\libraries\julia\conda\3\lib\site-packages\traitlets\traitlets.py", line 975, in __call__
    return self.func(*args, **kwargs)
  File "D:\libraries\julia\conda\3\lib\site-packages\nbconvert\preprocessors\svg2pdf.py", line 57, in _inkscape_version_default
    p = subprocess.Popen([self.inkscape, '--version'],
  File "D:\libraries\julia\conda\3\lib\subprocess.py", line 854, in __init__
    self._execute_child(args, executable, preexec_fn, close_fds,
  File "D:\libraries\julia\conda\3\lib\subprocess.py", line 1307, in _execute_child
    hp, ht, pid, tid = _winapi.CreateProcess(executable, args,
PermissionError: [WinError 5] Access is denied
daholzfeind commented 4 years ago

I had a similar issue while trying to convert a notebook to PDF via LaTeX in CoCalc.

Error: [NbConvertApp] Converting notebook file-1.ipynb to pdf
Traceback (most recent call last):
  File "/usr/local/lib/python3.8/dist-packages/traitlets/traitlets.py", line 528, in get
    value = obj._trait_values[self.name]
KeyError: 'command'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.8/dist-packages/traitlets/traitlets.py", line 528, in get
    value = obj._trait_values[self.name]
KeyError: 'inkscape_version'

During handling of the above exception, another exception occurred:

[...]

RuntimeError: Unable to find inkscape executable --version

When I try to run ìnkscape --version, I obtain the following error(inkscape:925):Gtk-WARNING **: 13:44:30.837: cannot open display: :0.

To display the version of inkscape in a terminal, one needs to add the -z argument, i.e.

~/$ inkscape -z -V
Inkscape 0.92.5 (2060ec1f9f, 2020-04-08)

So maybe adding -z in this line https://github.com/jupyter/nbconvert/blob/f66ec517275f7c61bb5a36a5d3496ba73005d659/nbconvert/preprocessors/svg2pdf.py#L57 will fix the issues, regarding the errors above.

CC @haraldschilly

lunarspectrum commented 3 years ago

This solves it, although os.popen() uses subprocess.Popen(), so it's clearly a kludge. Digging into the code for os.popen would probably reveal a cleaner fix. But this works.

Beginning here: https://github.com/jupyter/nbconvert/blob/f66ec517275f7c61bb5a36a5d3496ba73005d659/nbconvert/preprocessors/svg2pdf.py#L57 Make the following change.

try:
    p = subprocess.Popen([self.inkscape, '--version'],
    stdout=subprocess.PIPE,
    stderr=subprocess.PIPE)
    output, _ = p.communicate()
    if p.returncode != 0:
        raise RuntimeError("Unable to find inkscape executable --version")
except PermissionError:
    with os.popen(self.inkscape + ' --version') as p:
        output = p.read().encode()
lunarspectrum commented 3 years ago

Actually, I returned to this and looked inside os.py. Nothing special about the way subprocess.Popen is called there. Changing line 57 to:

p = subprocess.Popen(self.inkscape + ' --version',
        stdout=subprocess.PIPE,
        stderr=subprocess.PIPE)
output, _ = p.communicate()

fixes it. Does this break it on other platforms? If so, could do:

cmd = [inkscape,'--version']
if sys.platform == 'win32':
    cmd = ' '.join(cmd) #fix bug on win32
p = subprocess.Popen(cmd,
        stdout=subprocess.PIPE,
        stderr=subprocess.PIPE)
output, _ = p.communicate()
MSeal commented 3 years ago

Sorry I've been away for a while -- Popen should be doing the ' '.join (see Popen docs) but I'm ok with forcing the issue and implementing the windows specific solution as last proposed here. Doing this for all systems can raise issues, so let's only do it for win32

lunarspectrum commented 3 years ago

Great! It seems that the function subprocess.list2cmdline in the subprocess module does something more complicated than join and doesn't handle the windows path correctly.

Thank you and happy new year!

daholzfeind commented 3 years ago

@MSeal Does this also solves my issues mentioned above? Which happened in a Linux environment and not in Windows.

lunarspectrum commented 3 years ago

@MSeal, it turns out that the reason it's failing on windows is semi-intentional: See second comment in https://bugs.python.org/issue37659

@daholzfeind, did you try the fix in your local copy of the code and run it? It looks like a potentially different issue.

daholzfeind commented 3 years ago

@lunarspectrum I worked on this issue 2 months ago, so i cannot test it right now. But what i did, according to git, to fix the gtk error is the following:

$ git diff
diff --git a/nbconvert/preprocessors/svg2pdf.py b/nbconvert/preprocessors/svg2pdf.py
index 9ccaee1c..ee27e926 100644
--- a/nbconvert/preprocessors/svg2pdf.py
+++ b/nbconvert/preprocessors/svg2pdf.py
@@ -54,7 +54,7 @@ class SVG2PDFPreprocessor(ConvertFiguresPreprocessor):

     @default('inkscape_version')
     def _inkscape_version_default(self):
-        p = subprocess.Popen([self.inkscape, '--version'],
+        p = subprocess.Popen([self.inkscape, '-z --version'],
             stdout=subprocess.PIPE,
             stderr=subprocess.PIPE)
         output, _ = p.communicate()

But this only works for inkscape versions < 1.x.x. Above 1.x.x the passed argument raises a deprecation warning --without-gui= is deprecated.

So to fix my issue we could do a try, except. one with the -z argument for old inkscape versions and one without -z.

On my local machine i installed the latest inkscape version for testing reasons. Heres the output:

$ inkscape -z --version
Warning: Option --without-gui= is deprecated
Inkscape 1.1-dev (1:1.0+devel+202101062226+8077427f6d)
    Pango version: 1.44.7

In CoCalc the inkscape version depends on your ubuntu base image. I think i have the 20.04 there. This is the output in the "virtual" Terminal:

~$ inkscape -z --version
Inkscape 0.92.5 (2060ec1f9f, 2020-04-08)
~$ inkscape --version

(inkscape:747): Gtk-WARNING **: 08:38:02.726: cannot open display: :0
~$ 
daholzfeind commented 1 year ago

@MSeal Are there any news for this issue. I still encouter it with version 7.2.5 of nbconvert and version 0.92.5 of Inkscape.

I also see a lot of similar issues corresponding to this problem:

Some issues are closed, stated they solve the issue, but thats not the case if you use an Inkscape version < 1.0.0.