jupyter / nbconvert

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

image in mrkdown cell failed pdf conversion from ipynb #1538

Open logicalbhanu opened 3 years ago

logicalbhanu commented 3 years ago

while converting my ipynb file with an image in markdown cell, where image is imported with command ![](AmazonReview.png) , i am getting this below error(only mentioning the part of error which seems relevant to me, as the whole error is too long), moreover importing image through code cell, with command from IPython.display import Image Image(filename = "AmazonReview.png") is creating no problem while conversion, also i tried converting notebook to latex first and then to pdf by using pdflatex , but didn't succeed either. I even tried to change the name of notebook with no spaces in it, with no success.

nbconvert failed: PDF creating failed, captured latex output: Failed to run "['xelatex', 'notebook.tex', '-quiet']" command: This is XeTeX, Version 3.14159265-2.6-0.999991 (TeX Live 2019/Debian) (preloaded format=xelatex) restricted \write18 enabled. entering extended mode (./notebook.tex LaTeX2e <2020-02-02> patch level 2

and at last, i am getting below part of the error

(/usr/share/texlive/texmf-dist/tex/latex/ucs/ucsencs.def) (/usr/share/texlive/texmf-dist/tex/latex/hyperref/nameref.sty (/usr/share/texlive/texmf-dist/tex/latex/refcount/refcount.sty) (/usr/share/texlive/texmf-dist/tex/generic/gettitlestring/gettitlestring.sty))

Package hyperref Warning: Rerun to get /PageLabels entry.

(/usr/share/texlive/texmf-dist/tex/latex/amsfonts/umsa.fd) (/usr/share/texlive/texmf-dist/tex/latex/amsfonts/umsb.fd) (/usr/share/texlive/texmf-dist/tex/latex/jknapltx/ursfs.fd)

LaTeX Warning: No \author given.

(/usr/share/texlive/texmf-dist/tex/generic/stringenc/se-ascii-print.def) Underfull \hbox (badness 10000) in paragraph at lines 419--420

LaTeX Warning: File `AmazonReview.png' not found on input line 422.

! Unable to load picture or PDF file 'AmazonReview.png'.

} l.422 \includegraphics{AmazonReview.png} ? ! Emergency stop. } l.422 \includegraphics{AmazonReview.png} No pages of output. Transcript written on notebook.log. simply adding any image to markdown cell with command `![](AmazonReview.png)` in a jupyter notebook would reproduce the issue. **Nbconvert version:** 6.0.7
logicalbhanu commented 3 years ago

I have found a strange behavior, which is if I am putting my ipynb file and its respective image file (amazonreview.png) in the directory at which virtual environment is installed, then I am able to generate the pdf from the ipynb notebook, moreover, if i put the ipynb and image file in some other directory inside the virtual environment directory, then also pdf is getting generated, but if the nested directories are more in number, then pdf can't be generated.

so it seems to me like some sort of weird issue regarding access of image file while creating the pdf file from ipynb file, depending upon a number of nested directories(i know this sounds dumb, but this is what I have observed).

the directory structure for the ipynb file from the base directory(in which the virtual environment has been installed) is as follows:

directory_of_virtual_environment --> notes_and_notebooks -->Module_3_Natural_language_processing --> 1_Real_world_problem:_Predict_rating_given_product_reviews_on_Amazon --> Amazon_Fine_Food_Reviews_Analysis.ipynb and AmazonReview.png