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

PermissionError: [WinError 5] when trying to convert to PDF #1525

Open
netotz opened this issue Feb 22, 2021 · 5 comments
Open

PermissionError: [WinError 5] when trying to convert to PDF #1525

netotz opened this issue Feb 22, 2021 · 5 comments

Comments

@netotz
Copy link

netotz commented Feb 22, 2021

Trying to convert a Jupyter notebook to PDF throws the following trace error:

[NbConvertApp] Converting notebook evidencia1/ejercicios.ipynb to pdf
Traceback (most recent call last):
  File "c:\users\netoo\appdata\local\programs\python\python38\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 "c:\users\netoo\appdata\local\programs\python\python38\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 "c:\users\netoo\appdata\local\programs\python\python38\lib\runpy.py", line 194, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "c:\users\netoo\appdata\local\programs\python\python38\lib\runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "C:\Users\netoo\AppData\Local\Programs\Python\Python38\Scripts\jupyter-nbconvert.EXE\__main__.py", line 7, in <module>
  File "c:\users\netoo\appdata\local\programs\python\python38\lib\site-packages\jupyter_core\application.py", line 270, in launch_instance
    return super(JupyterApp, cls).launch_instance(argv=argv, **kwargs)
  File "c:\users\netoo\appdata\local\programs\python\python38\lib\site-packages\traitlets\config\application.py", line 845, in launch_instance
    app.start()
  File "c:\users\netoo\appdata\local\programs\python\python38\lib\site-packages\nbconvert\nbconvertapp.py", line 350, in start
    self.convert_notebooks()
  File "c:\users\netoo\appdata\local\programs\python\python38\lib\site-packages\nbconvert\nbconvertapp.py", line 524, in convert_notebooks
    self.convert_single_notebook(notebook_filename)
  File "c:\users\netoo\appdata\local\programs\python\python38\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 "c:\users\netoo\appdata\local\programs\python\python38\lib\site-packages\nbconvert\nbconvertapp.py", line 418, in export_single_notebook
    output, resources = self.exporter.from_filename(notebook_filename, resources=resources)
  File "c:\users\netoo\appdata\local\programs\python\python38\lib\site-packages\nbconvert\exporters\exporter.py", line 181, in from_filename
    return self.from_file(f, resources=resources, **kw)
  File "c:\users\netoo\appdata\local\programs\python\python38\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 "c:\users\netoo\appdata\local\programs\python\python38\lib\site-packages\nbconvert\exporters\pdf.py", line 168, in from_notebook_node
    latex, resources = super().from_notebook_node(
  File "c:\users\netoo\appdata\local\programs\python\python38\lib\site-packages\nbconvert\exporters\latex.py", line 77, in from_notebook_node
    return super().from_notebook_node(nb, resources, **kw)
  File "c:\users\netoo\appdata\local\programs\python\python38\lib\site-packages\nbconvert\exporters\templateexporter.py", line 369, in from_notebook_node
    nb_copy, resources = super().from_notebook_node(nb, resources, **kw)
  File "c:\users\netoo\appdata\local\programs\python\python38\lib\site-packages\nbconvert\exporters\exporter.py", line 143, in from_notebook_node
    nb_copy, resources = self._preprocess(nb_copy, resources)
  File "c:\users\netoo\appdata\local\programs\python\python38\lib\site-packages\nbconvert\exporters\exporter.py", line 318, in _preprocess
    nbc, resc = preprocessor(nbc, resc)
  File "c:\users\netoo\appdata\local\programs\python\python38\lib\site-packages\nbconvert\preprocessors\base.py", line 47, in __call__
    return self.preprocess(nb, resources)
  File "c:\users\netoo\appdata\local\programs\python\python38\lib\site-packages\nbconvert\preprocessors\base.py", line 69, in preprocess
    nb.cells[index], resources = self.preprocess_cell(cell, resources, index)
  File "c:\users\netoo\appdata\local\programs\python\python38\lib\site-packages\nbconvert\preprocessors\convertfigures.py", line 45, in preprocess_cell
    output.data[self.to_format] = self.convert_figure(
  File "c:\users\netoo\appdata\local\programs\python\python38\lib\site-packages\nbconvert\preprocessors\svg2pdf.py", line 125, in convert_figure
    shell = self.command.format(from_filename=input_filename,
  File "c:\users\netoo\appdata\local\programs\python\python38\lib\site-packages\traitlets\traitlets.py", line 575, in __get__
    return self.get(obj, cls)
  File "c:\users\netoo\appdata\local\programs\python\python38\lib\site-packages\traitlets\traitlets.py", line 538, in get
    default = obj.trait_defaults(self.name)
  File "c:\users\netoo\appdata\local\programs\python\python38\lib\site-packages\traitlets\traitlets.py", line 1578, in trait_defaults
    return self._get_trait_default_generator(names[0])(self)
  File "c:\users\netoo\appdata\local\programs\python\python38\lib\site-packages\traitlets\traitlets.py", line 975, in __call__
    return self.func(*args, **kwargs)
  File "c:\users\netoo\appdata\local\programs\python\python38\lib\site-packages\nbconvert\preprocessors\svg2pdf.py", line 77, in _command_default
    major_verison = self.inkscape_version.split('.')[0]
  File "c:\users\netoo\appdata\local\programs\python\python38\lib\site-packages\traitlets\traitlets.py", line 575, in __get__
    return self.get(obj, cls)
  File "c:\users\netoo\appdata\local\programs\python\python38\lib\site-packages\traitlets\traitlets.py", line 538, in get
    default = obj.trait_defaults(self.name)
  File "c:\users\netoo\appdata\local\programs\python\python38\lib\site-packages\traitlets\traitlets.py", line 1578, in trait_defaults
    return self._get_trait_default_generator(names[0])(self)
  File "c:\users\netoo\appdata\local\programs\python\python38\lib\site-packages\traitlets\traitlets.py", line 975, in __call__
    return self.func(*args, **kwargs)
  File "c:\users\netoo\appdata\local\programs\python\python38\lib\site-packages\nbconvert\preprocessors\svg2pdf.py", line 57, in _inkscape_version_default
    p = subprocess.Popen([self.inkscape, '--version'],
  File "c:\users\netoo\appdata\local\programs\python\python38\lib\subprocess.py", line 854, in __init__
    self._execute_child(args, executable, preexec_fn, close_fds,
  File "c:\users\netoo\appdata\local\programs\python\python38\lib\subprocess.py", line 1307, in _execute_child
    hp, ht, pid, tid = _winapi.CreateProcess(executable, args,
PermissionError: [WinError 5] Acceso denegado

Before that I was getting an error related to Inkscape but I reinstalled it and followed this answer: #456 (comment)

nbconvert version: 6.0.7

@netotz netotz changed the title PermissionError: [WinError 5] PermissionError: [WinError 5] when trying to convert to PDF Feb 23, 2021
@netotz
Copy link
Author

netotz commented Feb 23, 2021

My temporary solution was to use the absolute path as a string literal where I installed Inkscape instead of calling self.inkscape, in my case the path is 'C:\\Program Files\\Inkscape\\inkscape.exe':

p = subprocess.Popen([self.inkscape, '--version'],

in that line I have p = subprocess.Popen(['C:\\Program Files\\Inkscape\\inkscape.exe', '--version'].

I printed self.inkscape and the output was 'C:\Program Files\Inkscape\inkscape.exe'. I thought it was because of the double back slash so I tried os.path.abspath(self.inkscape) but it was adding at the beginning the path from where I was calling the command. I also tried pathlib.Path(self.inkscape) but it didn't work, so I have no idea what the problem could be.

By the way as you can see, this is previous to 5852762 as that change doesn't work for me.

@technic
Copy link

technic commented Apr 2, 2021

May I kindly ask to put this to high priority? There are already a pull requests which shall fix this issue, e.g. #1512. @MSeal Is there a way I can help to move it forward?

@technic
Copy link

technic commented Apr 2, 2021

By the way, this is probably a duplicate of #1447

@g0h3y6
Copy link

g0h3y6 commented Jun 12, 2021

By Changing the version of nbconvert to 5.5.0, it did work!
I think the developers of nbconvert should refer to the version 5.5.0?
image

@g0h3y6
Copy link

g0h3y6 commented Jun 12, 2021

By Changing the version of nbconvert to 5.5.0, it did work!
I think the developers of nbconvert should refer to the version 5.5.0?
image

I didn't use any other method but added inkscape to system path before compiling GAN_Human.ipynb to latex. Anyone else met this problem could take this into consideration...

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

No branches or pull requests

3 participants