microsoft / vscode-jupyter

VS Code Jupyter extension
https://marketplace.visualstudio.com/items?itemName=ms-toolsai.jupyter
MIT License
1.28k stars 289 forks source link

Export as pdf masks errors when it fails #710

Closed djbhalodiya closed 3 years ago

djbhalodiya commented 4 years ago

Issue Type: Bug

PDF exported but with 0(zero) file size

Extension version: 2020.7.96456 VS Code version: Code - Insiders 1.48.0-insider (15ada625f20086007e2c4aa0d760234360cd648f, 2020-07-30T14:43:12.691Z) OS version: Windows_NT x64 10.0.19041

System Info |Item|Value| |---|---| |CPUs|Intel(R) Core(TM) i3-5005U CPU @ 2.00GHz (4 x 1995)| |GPU Status|2d_canvas: enabled
flash_3d: enabled
flash_stage3d: enabled
flash_stage3d_baseline: enabled
gpu_compositing: enabled
multiple_raster_threads: enabled_on
oop_rasterization: disabled_off
opengl: enabled_on
protected_video_decode: unavailable_off
rasterization: enabled
skia_renderer: disabled_off_ok
video_decode: enabled
vulkan: disabled_off
webgl: enabled
webgl2: enabled| |Load (avg)|undefined| |Memory (System)|7.90GB (2.98GB free)| |Process Argv|C:\Users\Dharmesh\Downloads\Mini-Project\BDPV - Mini Project\Mini Project.ipynb --crash-reporter-id 4086b05a-5e70-42e1-b21c-dd41020609e7| |Screen Reader|no| |VM|0%|
joyceerhl commented 4 years ago

Hi @djbhalodiya, thanks for the bug report! Just to be sure I understand, did the extension report a successful export attempt even though the exported PDF was empty? What did the notebook that you were exporting look like?

djbhalodiya commented 4 years ago

image

mo-ian-watkins commented 4 years ago

Even with the most simple of notebooks, e.g. helloworld, I'm also getting what looks like a successful PDF export but file size is 0 bytes.

Stable VSCode 1.48, latest Python extension, Windows 10 and Tex is installed.

frederickjjoubert commented 4 years ago

Hi all, I'm getting the same problem. I am trying to export my *.ipynb (Jupyter Notebook) but the PDF exported with 0(zero) file size.

There is no export errors from VSCode, it looks like it's exporting successfully.

Also VSCode 1.48, Microsoft Python Extension v2020.8.101144, Windows 10 Pro v19041.450.

dpizzino commented 4 years ago

Same issue. Exporting a *.ipynb to a PDF results in a 0 byte file that cannot be opened. No errors from VSCode.

VSCode 1.48, Microsoft Python Extension v2020.8.101144, Windows 10

tomyummmm commented 4 years ago

Same issue faced for both html and PDF export. Both output is 0 byte file.

VSCode 1.48.2, Microsoft Python Extension v2020.8.103604, Windows 10

nini074 commented 4 years ago

Experiencing the same problem: PDF export of notebook appears successful but the result is a 0 byte file that will not open.

VSCode 1.48.2, Microsoft Python Extension v2020.8.105045, Mac OS Catalina

rchiodo commented 4 years ago

Can somebody try this on the failing notebook? It should show why the PDF export is failing.

jupyter nbconvert file.ipynb --to pdf --output file.pdf

It looks like we only assume a failure (and show stderr) when the pdf is not created. If it's created with zero length we're likely masking the error.

dpizzino commented 4 years ago

Here's the output from jupyter nbconvert file.ipynb --to pdf --output file.pdf

[NbConvertApp] Writing 20848 bytes to .\notebook.tex [NbConvertApp] Building PDF Traceback (most recent call last): File "...\miniconda3\envs\test\Scripts\jupyter-nbconvert-script.py", line 10, in sys.exit(main()) File "...\miniconda3\envs\test\lib\site-packages\jupyter_core\application.py", line 270, in launch_instance return super(JupyterApp, cls).launch_instance(argv=argv, kwargs) File "...\miniconda3\envs\test\lib\site-packages\traitlets\config\application.py", line 664, in launch_instance app.start() File "...\miniconda3\envs\test\lib\site-packages\nbconvert\nbconvertapp.py", line 340, in start self.convert_notebooks() File "...\miniconda3\envs\test\lib\site-packages\nbconvert\nbconvertapp.py", line 510, in convert_notebooks self.convert_single_notebook(notebook_filename) File "...\miniconda3\envs\test\lib\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 "...\miniconda3\envs\test\lib\site-packages\nbconvert\nbconvertapp.py", line 410, in export_single_notebook output, resources = self.exporter.from_filename(notebook_filename, resources=resources) File "...\miniconda3\envs\test\lib\site-packages\nbconvert\exporters\exporter.py", line 179, in from_filename return self.from_file(f, resources=resources, kw) File "...\miniconda3\envs\test\lib\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 "...\miniconda3\test\geopro\lib\site-packages\nbconvert\exporters\pdf.py", line 185, in from_notebook_node self.run_latex(tex_file) File "...\miniconda3\envs\test\lib\site-packages\nbconvert\exporters\pdf.py", line 155, in run_latex return self.run_command(self.latex_command, filename, File "...\miniconda3\envs\test\lib\site-packages\nbconvert\exporters\pdf.py", line 112, in run_command raise OSError("{formatter} not found on PATH, if you have not installed " OSError: xelatex not found on PATH, if you have not installed xelatex you may need to do so. Find further instructions at https://nbconvert.readthedocs.io/en/latest/install.html#installing-tex.

greazer commented 4 years ago

Sorry for the trouble here. While we can't fix this issue as it's not in our codebase, we'll investigate providing more discoverable error information in an upcoming release. As a workaround, please consider exporting to html, then via Chrome or Edge (or probably other browsers) you can print the page to PDF.

tomyummmm commented 4 years ago

Can somebody try this on the failing notebook? It should show why the PDF export is failing.

jupyter nbconvert file.ipynb --to pdf --output file.pdf

It looks like we only assume a failure (and show stderr) when the pdf is not created. If it's created with zero length we're likely masking the error.

I ran the code in terminal and it works, the output of jupyter nbconvert pdf works as expected, like running the code in my cmd.

(venv) C:\Users\mervi\Documents\MEGAsync\School\Y3Sem1\CS3237 Introduction to IoT>jupyter nbconvert "c:\Users\mervi\Documents\MEGAsync\School\Y3Sem1\CS3237 Introduction to IoT\Labs\cs3237lab1\CS3237Lab1.ipynb" --to pdf --output CS3237Lab1.pdf [NbConvertApp] Converting notebook c:\Users\mervi\Documents\MEGAsync\School\Y3Sem1\CS3237 Introduction to IoT\Labs\cs3237lab1\CS3237Lab1.ipynb to pdf [NbConvertApp] Writing 90640 bytes to .\notebook.tex [NbConvertApp] Building PDF [NbConvertApp] Running xelatex 3 times: ['xelatex', '.\notebook.tex', '-quiet'] [NbConvertApp] Running bibtex 1 time: ['bibtex', '.\notebook'] [NbConvertApp] WARNING | b had problems, most likely because there were no citations [NbConvertApp] PDF successfully created [NbConvertApp] Writing 380004 bytes to c:\Users\mervi\Documents\MEGAsync\School\Y3Sem1\CS3237 Introduction to IoT\Labs\cs3237lab1\CS3237Lab1.pdf

The problem here is the export function. It still outputs 0kb file.

edit: Also, VSC does not prompt for the user to install TeX, causing the error the other user faced above. Is there a way to get terminal to show the verbose output of what it is doing? Like when i click on export to > pdf, i want to see whats it doing

AlexWithYou commented 4 years ago

I have same issue here. Even though HTML format works well, the pdf format failed

orion160 commented 4 years ago

It happens because to convert a jupyter notebook to pdf it needs pandadoc and latex installed in the system, so vs code should notify about the required dependencies.

tomyummmm commented 4 years ago

It happens because to convert a jupyter notebook to pdf it needs pandadoc and latex installed in the system, so vs code should notify about the required dependencies.

I do have both installed. Like i mentioned, VSCode DOES NOT notify when they arent installed. And the error of output to 0kb still occurs when using the export to function. When using nbconvert directly in terminal, it works as expected.

rchiodo commented 4 years ago

Note: We're not going to search for PDF dependencies. The fix here will simply be to list out the error when we get a zero byte PDF file.

tomyummmm commented 4 years ago

Note: We're not going to search for PDF dependencies. The fix here will simply be to list out the error when we get a zero byte PDF file.

Screenshot_2020-09-10-08-34-06-974_org mozilla firefox

Then you guys better update your documentation as well if you arent going to search and prompt the user to install TeX

JanHomann commented 4 years ago

Same here. Neither conversion to Python Script, HTML or PDF works. exporting to Python Script produces no code, and exporting to HTML and PDF returns empty files. The command jupyter nbconvert my_file.ipynb --to pdf --output file.pdf works and produces valid output.

rchiodo commented 4 years ago

If this command is working:

jupyter nbconvert my_file.ipynb --to pdf --output file.pdf 

Then I would guess you're not using the same environment we're using.

Your best bet to reproduce the problem with the command line is to: 1) Run the 'Python : Create Terminal` command (this should start the same environment) 1) Then run jupyter nbconvert file.ipynb --to pdf --output file.pdf

Under the covers, our 'Export to pdf' is running that exact command.

JanHomann commented 4 years ago

Even when i do that, it still works.

[NbConvertApp] Converting notebook heatmap_unequal_spacing.ipynb to pdf
/Users/janhomann/Dropbox/Science/Publications - in progress and done/4 day passive exposure/4_day_passive_exposure/.venv/lib/python3.8/site-packages/nbconvert/filters/datatypefilter.py:39: UserWarning: Your element with mimetype(s) dict_keys(['application/vnd.plotly.v1+json']) is not able to be represented.
  warn("Your element with mimetype(s) {mimetypes}"
[NbConvertApp] Writing 25326 bytes to ./notebook.tex
[NbConvertApp] Building PDF
[NbConvertApp] Running xelatex 3 times: ['xelatex', './notebook.tex', '-quiet']
[NbConvertApp] Running bibtex 1 time: ['bibtex', './notebook']
[NbConvertApp] WARNING | bibtex had problems, most likely because there were no citations
[NbConvertApp] PDF successfully created
[NbConvertApp] Writing 21059 bytes to file1.pdf

The plotly figures are gone, but i suspect that's something that requires a more sophisticated converter.

rchiodo commented 4 years ago

If you install this build: https://github.com/microsoft/vscode-python/suites/1180411345/artifacts/17273285 it should at least show you the error we're getting.

JanHomann commented 4 years ago

If you install this build: https://github.com/microsoft/vscode-python/suites/1180411345/artifacts/17273285 it should at least show you the error we're getting.

I don't know how to install this and if installing this will screw up even more or change my configurations.

rchiodo commented 4 years ago

That's a vsix file. You can install it through the extensions tab by clicking on the three dots and picking 'Install from VSIX'. It's how VS code packages extensions.

It's an internal build so it could be buggy with other things but it won't change any config settings.

Once you're done trying it, you can uninstall it and reinstall the general release of the python extension again through the extensions tab.

JanHomann commented 4 years ago

Okay. Exporting as Python Script gives no error and the output is empty. Exporting to HTML or PDF now gives an error

Export failed. Export failed. Please check the 'Python' output panel for further details.

(yes, it writes export failed twice) and i can see something in the python console. Which is a lot of stuff, but essentially boils down to:

It looks like it is using the wrong environment.

~/Dropbox/Science/Git Repositories/test/.venv/bin/python ~/.vscode/extensions/ms-python.python-2020.9.250501055-dev/pythonFiles/pyvsc-run-isolated.py jupyter nbconvert /var/folders/wd/84hhc3856319p5hvs7t7qffw0000gq/T/9338d0ff-5175-46e7-92a2-9f9a28810c44/heatmap_unequal_spacing.ipynb --to html --output tmp-50038ORAeI1XOWybC.html --output-dir /var/folders/wd/84hhc3856319p5hvs7t7qffw0000gq/T
Error 2020-09-11 20:22:56: Export failed [Error: Traceback (most recent call last):
  File "/Users/janhomann/Dropbox/Science/Git Repositories/test/.venv/bin/jupyter-nbconvert", line 12, in <module>
    sys.exit(main())
  File "/Users/janhomann/Dropbox/Science/Git Repositories/test/.venv/lib/python3.8/site-packages/jupyter_core/application.py", line 270, in launch_instance
    return super(JupyterApp, cls).launch_instance(argv=argv, **kwargs)
  File "/Users/janhomann/Dropbox/Science/Git Repositories/test/.venv/lib/python3.8/site-packages/traitlets/config/application.py", line 838, in launch_instance
    app.start()
  File "/Users/janhomann/Dropbox/Science/Git Repositories/test/.venv/lib/python3.8/site-packages/nbconvert/nbconvertapp.py", line 340, in start
    self.convert_notebooks()
  File "/Users/janhomann/Dropbox/Science/Git Repositories/test/.venv/lib/python3.8/site-packages/nbconvert/nbconvertapp.py", line 500, in convert_notebooks
    self.exporter = cls(config=self.config)
  File "/Users/janhomann/Dropbox/Science/Git Repositories/test/.venv/lib/python3.8/site-packages/nbconvert/exporters/templateexporter.py", line 263, in __init__
    super(TemplateExporter, self).__init__(config=config, **kw)
  File "/Users/janhomann/Dropbox/Science/Git Repositories/test/.venv/lib/python3.8/site-packages/nbconvert/exporters/exporter.py", line 110, in __init__
    self._init_preprocessors()
  File "/Users/janhomann/Dropbox/Science/Git Repositories/test/.venv/lib/python3.8/site-packages/nbconvert/exporters/exporter.py", line 264, in _init_preprocessors
    self.register_preprocessor(preprocessor, enabled=True)
  File "/Users/janhomann/Dropbox/Science/Git Repositories/test/.venv/lib/python3.8/site-packages/nbconvert/exporters/exporter.py", line 225, in register_preprocessor
    preprocessor_cls = import_item(preprocessor)
  File "/Users/janhomann/Dropbox/Science/Git Repositories/test/.venv/lib/python3.8/site-packages/traitlets/utils/importstring.py", line 30, in import_item
    module = __import__(package, fromlist=[obj])
ModuleNotFoundError: No module named 'jupyter_contrib_nbextensions'

    at a.executeCommand (/Users/janhomann/.vscode/extensions/ms-python.python-2020.9.250501055-dev/out/client/extension.js:1:554651)
    at runMicrotasks (<anonymous>)
    at processTicksAndRejections (internal/process/task_queues.js:94:5)
    at async a.export (/Users/janhomann/.vscode/extensions/ms-python.python-2020.9.250501055-dev/out/client/extension.js:56:266739)
    at async _.exportToFormat (/Users/janhomann/.vscode/extensions/ms-python.python-2020.9.250501055-dev/out/client/extension.js:56:263875)
    at async _.performExport (/Users/janhomann/.vscode/extensions/ms-python.python-2020.9.250501055-dev/out/client/extension.js:56:262910)
    at async _.export (/Users/janhomann/.vscode/extensions/ms-python.python-2020.9.250501055-dev/out/client/extension.js:56:262428)
    at async f.export (/Users/janhomann/.vscode/extensions/ms-python.python-2020.9.250501055-dev/out/client/extension.js:24:295252)]
rchiodo commented 4 years ago

It sounds like an environment issue if it works with the terminal. Does the terminal use that .venv too?

JanHomann commented 4 years ago

It sounds like an environment issue if it works with the terminal. Does the terminal use that .venv too?

It's definitely the wrong environment. The terminal uses a different environment.

rchiodo commented 4 years ago

Ah okay. Looks like there's a bug with picking the interpreter to use. It's this code here:

    protected async getExecutionService(source: Uri): Promise<IPythonExecutionService | undefined> {
        const interpreter = await this.jupyterService.getSelectedInterpreter(); <-- This should be something different.
        if (!interpreter) {
            return;
        }
        return this.pythonExecutionFactory.createActivatedEnvironment({
            resource: source,
            interpreter,
            allowEnvironmentFetchExceptions: false,
            bypassCondaExecution: true
        });
    }

Thanks for trying that out. We should be able to fix this for more people now.

rchiodo commented 4 years ago

If it works with the terminal (like it does for @JanHomann ) you might be able to work around this by running 'Python : Select interpreter to start Jupyter' and picking the python interpreter you're using for your notebook.

That line of code I marked as incorrect is using the 'jupyter interpreter' when it should be using the matching interpreter.

JanHomann commented 4 years ago

I can confirm that when i pick that particular environment then

jupyter nbconvert heatmap_unequal_spacing.ipynb --to pdf --output file2.pdf   

gives exactly the same Traceback. Also, this is an environment that's just a dump. I don't even know why it switches to that one.

JanHomann commented 4 years ago

If it works with the terminal (like it does for @JanHomann ) you might be able to work around this by running 'Python : Select interpreter to start Jupyter' and picking the python interpreter you're using for your notebook.

That line of code I marked as incorrect is using the 'jupyter interpreter' when it should be using the matching interpreter.

That fixed it!

tomyummmm commented 4 years ago

The above solved my issues, im able to output to pdf now. But the normal python extension will still masks certain errors, like having images in the notebook and export to a 0kb PDF file.

Expected: Exporting to PDF should fail, and show the below error (taken from the output of your dev version of python extension), and not export to a 0kb PDF file. This is a nbconvert issue as far as i can tell. Any help would be appreciated.

Error 2020-09-12 11:05:43: Export failed [Error: [NbConvertApp] Converting notebook c:\Users\mervi\AppData\Local\Temp\4eb8aa22-3615-4487-91c9-58fcbb332074\CS3237Lab1.ipynb to pdf
[NbConvertApp] Writing 90640 bytes to .\notebook.tex
[NbConvertApp] Building PDF
[NbConvertApp] Running xelatex 3 times: ['xelatex', '.\\notebook.tex', '-quiet']
[NbConvertApp] CRITICAL | x failed: xelatex .\notebook.tex -quiet
notebook.tex:914: Unable to load picture or PDF file '

...

nbconvert.exporters.pdf.LatexFailed: PDF creating failed, captured latex output:
Failed to run "xelatex .\notebook.tex -quiet" command:
notebook.tex:914: Unable to load picture or PDF file '

    at a.executeCommand (c:\Users\mervi\.vscode\extensions\ms-python.python-2020.9.250501055-dev\out\client\extension.js:1:554651)
    at processTicksAndRejections (internal/process/task_queues.js:94:5)
    at async a.export (c:\Users\mervi\.vscode\extensions\ms-python.python-2020.9.250501055-dev\out\client\extension.js:56:267372)
    at async _.exportToFormat (c:\Users\mervi\.vscode\extensions\ms-python.python-2020.9.250501055-dev\out\client\extension.js:56:263807)
    at async _.performExport (c:\Users\mervi\.vscode\extensions\ms-python.python-2020.9.250501055-dev\out\client\extension.js:56:262910)
    at async _.export (c:\Users\mervi\.vscode\extensions\ms-python.python-2020.9.250501055-dev\out\client\extension.js:56:262428)
    at async f.export (c:\Users\mervi\.vscode\extensions\ms-python.python-2020.9.250501055-dev\out\client\extension.js:24:295252)]
Error 2020-09-12 12:20:15: If you have not installed xelatex (TeX) you will need to do so before you can export to PDF, for further instructions go to https://nbconvert.readthedocs.io/en/latest/install.html#installing-tex. 
To avoid installing xelatex (TeX) you might want to try exporting to HTML and using your browsers "Print to PDF" feature.

Also apparently you have the above error message

Error 2020-09-12 12:20:15: If you have not installed xelatex (TeX) you will need to do so before you can export to PDF, for further instructions go to https://nbconvert.readthedocs.io/en/latest/install.html#installing-tex. 
To avoid installing xelatex (TeX) you might want to try exporting to HTML and using your browsers "Print to PDF" feature.

I assume this is your prompt to install TeX according to the documentation?

tomyummmm commented 4 years ago

Also, it seems that when using the export to pdf function in VSCode, it uses the temporary path of the file, which causes issues if there is markdown which contains images/paths like ![iris](image/iris.png) as the images cannot be accessed. Is it possible to point directly to the actual location of the file so it can find the images for output?

c:\Users\mervi\AppData\Local\Temp\dcc79095-1fc7-46a0-b518-fac64cb83064\CS3237Lab1.ipynb --to pdf --output tmp-7848MYR8gzD6V4iU.pdf --output-dir ~\AppData\Local\Temp

c:\Users\mervi\Documents\MEGAsync\School\Y3Sem1\CS3237 Introduction to IoT\venv\Scripts\python.exe c:/Users/mervi/.vscode/extensions/ms-python.python-2020.9.250501055-dev/pythonFiles/pyvsc-run-isolated.py jupyter nbconvert c:\Users\mervi\AppData\Local\Temp\dcc79095-1fc7-46a0-b518-fac64cb83064\CS3237Lab1.ipynb --to pdf --output tmp-7848MYR8gzD6V4iU.pdf --output-dir ~\AppData\Local\Temp
Error 2020-09-12 13:33:32: Export failed [Error: [NbConvertApp] Converting notebook c:\Users\mervi\AppData\Local\Temp\dcc79095-1fc7-46a0-b518-fac64cb83064\CS3237Lab1.ipynb to pdf
[NbConvertApp] Writing 90870 bytes to .\notebook.tex
[NbConvertApp] Building PDF
[NbConvertApp] Running xelatex 3 times: ['xelatex', '.\\notebook.tex', '-quiet']
[NbConvertApp] CRITICAL | x failed: xelatex .\notebook.tex -quiet
notebook.tex:914: Unable to load picture or PDF file '
Traceback (most recent call last):
  File "C:\Users\mervi\AppData\Local\Programs\Python\Python37\lib\runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "C:\Users\mervi\AppData\Local\Programs\Python\Python37\lib\runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "C:\Users\mervi\Documents\MEGAsync\School\Y3Sem1\CS3237 Introduction to IoT\venv\Scripts\jupyter-nbconvert.EXE\__main__.py", line 7, in <module>
  File "c:\users\mervi\documents\megasync\school\y3sem1\cs3237 introduction to iot\venv\lib\site-packages\jupyter_core\application.py", line 270, in launch_instance
    return super(JupyterApp, cls).launch_instance(argv=argv, **kwargs)
  File "c:\users\mervi\documents\megasync\school\y3sem1\cs3237 introduction to iot\venv\lib\site-packages\traitlets\config\application.py", line 664, in launch_instance
    app.start()
  File "c:\users\mervi\documents\megasync\school\y3sem1\cs3237 introduction to iot\venv\lib\site-packages\nbconvert\nbconvertapp.py", line 340, in start
    self.convert_notebooks()
  File "c:\users\mervi\documents\megasync\school\y3sem1\cs3237 introduction to iot\venv\lib\site-packages\nbconvert\nbconvertapp.py", line 510, in convert_notebooks
    self.convert_single_notebook(notebook_filename)
  File "c:\users\mervi\documents\megasync\school\y3sem1\cs3237 introduction to iot\venv\lib\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 "c:\users\mervi\documents\megasync\school\y3sem1\cs3237 introduction to iot\venv\lib\site-packages\nbconvert\nbconvertapp.py", line 410, in export_single_notebook
    output, resources = self.exporter.from_filename(notebook_filename, resources=resources)
  File "c:\users\mervi\documents\megasync\school\y3sem1\cs3237 introduction to iot\venv\lib\site-packages\nbconvert\exporters\exporter.py", line 179, in from_filename
    return self.from_file(f, resources=resources, **kw)
  File "c:\users\mervi\documents\megasync\school\y3sem1\cs3237 introduction to iot\venv\lib\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 "c:\users\mervi\documents\megasync\school\y3sem1\cs3237 introduction to iot\venv\lib\site-packages\nbconvert\exporters\pdf.py", line 185, in from_notebook_node
    self.run_latex(tex_file)
  File "c:\users\mervi\documents\megasync\school\y3sem1\cs3237 introduction to iot\venv\lib\site-packages\nbconvert\exporters\pdf.py", line 156, in run_latex
    self.latex_count, log_error, raise_on_failure)
  File "c:\users\mervi\documents\megasync\school\y3sem1\cs3237 introduction to iot\venv\lib\site-packages\nbconvert\exporters\pdf.py", line 145, in run_command
    command=command, output=out))
nbconvert.exporters.pdf.LatexFailed: PDF creating failed, captured latex output:
Failed to run "xelatex .\notebook.tex -quiet" command:
notebook.tex:914: Unable to load picture or PDF file '

    at a.executeCommand (c:\Users\mervi\.vscode\extensions\ms-python.python-2020.9.250501055-dev\out\client\extension.js:1:554651)
    at processTicksAndRejections (internal/process/task_queues.js:94:5)
    at async a.export (c:\Users\mervi\.vscode\extensions\ms-python.python-2020.9.250501055-dev\out\client\extension.js:56:267372)
    at async _.exportToFormat (c:\Users\mervi\.vscode\extensions\ms-python.python-2020.9.250501055-dev\out\client\extension.js:56:263807)
    at async _.performExport (c:\Users\mervi\.vscode\extensions\ms-python.python-2020.9.250501055-dev\out\client\extension.js:56:262910)
    at async _.export (c:\Users\mervi\.vscode\extensions\ms-python.python-2020.9.250501055-dev\out\client\extension.js:56:262428)
    at async f.export (c:\Users\mervi\.vscode\extensions\ms-python.python-2020.9.250501055-dev\out\client\extension.js:24:295252)]
Error 2020-09-12 13:33:32: If you have not installed xelatex (TeX) you will need to do so before you can export to PDF, for further instructions go to https://nbconvert.readthedocs.io/en/latest/install.html#installing-tex. 
To avoid installing xelatex (TeX) you might want to try exporting to HTML and using your browsers "Print to PDF" feature.

Below is the path file used when running in terminal directly and outputs the pdf with images fine.

"c:\Users\mervi\Documents\MEGAsync\School\Y3Sem1\CS3237 Introduction to IoT\Labs\cs3237lab1\CS3237Lab1.ipynb" --to pdf --output "c:\Users\mervi\Desktop\cs3237 new.pdf"

> C:\Users\mervi\Documents\MEGAsync\School\Y3Sem1\CS3237 Introduction to IoT>jupyter nbconvert "c:\Users\mervi\Documents\MEGAsync\School\Y3Sem1\CS3237 Introduction to IoT\Labs\cs3237lab1\CS3237Lab1.ipynb" --to pdf --output "c:\Users\mervi\Desktop\cs3237 new.pdf"
[NbConvertApp] Converting notebook c:\Users\mervi\Documents\MEGAsync\School\Y3Sem1\CS3237 Introduction to IoT\Labs\cs3237lab1\CS3237Lab1.ipynb to pdf
[NbConvertApp] Writing 91104 bytes to notebook.tex
[NbConvertApp] Building PDF
[NbConvertApp] Running xelatex 3 times: ['xelatex', 'notebook.tex', '-quiet']
[NbConvertApp] Running bibtex 1 time: ['bibtex', 'notebook']
[NbConvertApp] WARNING | b had problems, most likely because there were no citations
[NbConvertApp] PDF successfully created
[NbConvertApp] Writing 380004 bytes to c:\Users\mervi\Desktop\cs3237 new.pdf
ragvri commented 4 years ago

Anyone got this to work?

IanMatthewHuff commented 4 years ago

Validated. At least for the basic concept that we should not be masking the error when the export fails.

image

WenukaB commented 3 years ago

I have same issue here. Even though HTML format works well, the pdf format failed

I'm facing the same problem

rchiodo commented 3 years ago

@WenukaB your jupyter output tab should show you what the failure is. Generally for export to PDF you have to install extra software.

See this: https://nbconvert.readthedocs.io/en/latest/install.html#installing-tex