nbconvert icon indicating copy to clipboard operation
nbconvert copied to clipboard

Unable to generate pdf (XeLaTeX not found on PATH)

Open ProsperousHeart opened this issue 6 years ago • 36 comments

So for the last almost year and a half, I have taught myself enough Python to work within the infrastructure of my company. I am trying to expand my knowledge of programming locally.

I am in the process of creating a training on NumPy using just Jupyter notebooks, but when I try to convert to PDF I get an error message with 500 server error:

nbconvert failed: 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.

I went to the page and installed all of the things ....

But to no avail.

Windows 10, anaconda distribution, python 3

ProsperousHeart avatar Apr 19 '18 04:04 ProsperousHeart

I tried doing it in the anaconda prompt and got this ...

(base) C:\WINDOWS\system32>cd "C:\Users\Kat\Documents\Programming\repo\TrainingUsingJupyter\NumPy\Exercise Answers"

(base) C:\Users\Kat\Documents\Programming\repo\TrainingUsingJupyter\NumPy\Exercise Answers>jupyter ntbconvert --to pdf "Basic NumPy Training 1 - ANSWERS - Copy.ipynb" Error executing Jupyter command 'ntbconvert': [Errno 'jupyter-ntbconvert' not found] 2

(base) C:\Users\Kat\Documents\Programming\repo\TrainingUsingJupyter\NumPy\Exercise Answers>

ProsperousHeart avatar Apr 19 '18 04:04 ProsperousHeart

At the command prompt, you've got ntbconvert instead of nbconvert.

That may just get you the same error that you saw from in the notebook editor. Unfortunately the pdf conversion relies on latex, which isn't very easy to install.

On Thu, 19 Apr 2018, 6:35 a.m. Kassandra Keeton, [email protected] wrote:

I tried doing it in the anaconda prompt and got this ...

(base) C:\WINDOWS\system32>cd "C:\Users\Kat\Documents\Programming\repo\TrainingUsingJupyter\NumPy\Exercise Answers"

(base) C:\Users\Kat\Documents\Programming\repo\TrainingUsingJupyter\NumPy\Exercise Answers>jupyter ntbconvert --to pdf "Basic NumPy Training 1 - ANSWERS - Copy.ipynb" Error executing Jupyter command 'ntbconvert': [Errno 'jupyter-ntbconvert' not found] 2

(base) C:\Users\Kat\Documents\Programming\repo\TrainingUsingJupyter\NumPy\Exercise Answers>

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/jupyter/nbconvert/issues/799#issuecomment-382607661, or mute the thread https://github.com/notifications/unsubscribe-auth/AAUA9Q8_iEtSXLWIPFd_ru2z400dS65Eks5tqBP5gaJpZM4TbIjz .

takluyver avatar Apr 19 '18 06:04 takluyver

Since you're on windows, I recommend downloading and installing miktex. It should automatically add LaTeX to the system path. Check if MiKTeX is anywhere on you're system. You can type that latex is in your path by:

From the command line type:

c\> latex --version

If this spits out a version, then I don't know what your problem is.

If this doesn't find a version, but MikTeX is installed on your system (It should be searchable from the start menu), then try to add C:\Program Files\MiKTeX 2.9\miktex\bin\x64 to your path. (Check that that is indeed where MikTeX is installed).

Alternatively, you can install miktex using chocolatey, which is a package manager for windows. This is the easiest way to install LaTeX on windows in my opinion. Follow the linked instructions to install chocolatey using an admin powershell. Then use:

choco install MikTeX

from an admin powershell. Chocolatey will shim MikTeX into the path, so it will certainly work.

t-makaro avatar May 18 '18 21:05 t-makaro

I have the same issue.

/miktex/bin/x64 is in my Path, and xelatex is installed, but I'm still getting this error.

[NbConvertApp] Converting notebook C:\Users\user\Documents\#work_stuff\anodot summary\prediction data\payoneer - lstm prophet.ipynb to pdf
[NbConvertApp] Writing 19232 bytes to C:\Users\user\Documents\#work_stuff\anodot summary\prediction data\notebook.tex
[NbConvertApp] Building PDF
Traceback (most recent call last):
  File "C:\Users\user\AppData\Local\conda\conda\envs\myenv\Scripts\jupyter-nbconvert-script.py", line 10, in <module>
    sys.exit(main())
  File "C:\Users\user\AppData\Local\conda\conda\envs\myenv\lib\site-packages\jupyter_core\application.py", line 266, in launch_instance
    return super(JupyterApp, cls).launch_instance(argv=argv, **kwargs)
  File "C:\Users\user\AppData\Local\conda\conda\envs\myenv\lib\site-packages\traitlets\config\application.py", line 658, in launch_instance
    app.start()
  File "C:\Users\user\AppData\Local\conda\conda\envs\myenv\lib\site-packages\nbconvert\nbconvertapp.py", line 325, in start
    self.convert_notebooks()
  File "C:\Users\user\AppData\Local\conda\conda\envs\myenv\lib\site-packages\nbconvert\nbconvertapp.py", line 493, in convert_notebooks
    self.convert_single_notebook(notebook_filename)
  File "C:\Users\user\AppData\Local\conda\conda\envs\myenv\lib\site-packages\nbconvert\nbconvertapp.py", line 464, in convert_single_notebook
    output, resources = self.export_single_notebook(notebook_filename, resources, input_buffer=input_buffer)
  File "C:\Users\user\AppData\Local\conda\conda\envs\myenv\lib\site-packages\nbconvert\nbconvertapp.py", line 393, in export_single_notebook
    output, resources = self.exporter.from_filename(notebook_filename, resources=resources)
  File "C:\Users\user\AppData\Local\conda\conda\envs\myenv\lib\site-packages\nbconvert\exporters\exporter.py", line 174, in from_filename
    return self.from_file(f, resources=resources, **kw)
  File "C:\Users\user\AppData\Local\conda\conda\envs\myenv\lib\site-packages\nbconvert\exporters\exporter.py", line 192, in from_file
    return self.from_notebook_node(nbformat.read(file_stream, as_version=4), resources=resources, **kw)
  File "C:\Users\user\AppData\Local\conda\conda\envs\myenv\lib\site-packages\nbconvert\exporters\pdf.py", line 175, in from_notebook_node
    rc = self.run_latex(tex_file)
  File "C:\Users\user\AppData\Local\conda\conda\envs\myenv\lib\site-packages\nbconvert\exporters\pdf.py", line 137, in run_latex
    self.latex_count, log_error)
  File "C:\Users\user\AppData\Local\conda\conda\envs\myenv\lib\site-packages\nbconvert\exporters\pdf.py", line 99, in run_command
    "at {link}.".format(formatter=command_list[0], link=link))
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.

lordgrenville avatar Sep 06 '18 14:09 lordgrenville

Same as @lordgrenville, has anyone been able to resolve this issue?

hansonap avatar Feb 06 '19 19:02 hansonap

The error occurs while building the PDF. Till this step, the notebook(.ipynb file) is already converted to .tex file. So, what you can do, open that .tex file using MikTex (Windows). 1

Change that to XeLatex and click the green play button besides it. It will ask for installations using a pop-up box. Install all. Then, you will have your pdf for that notebook.

Monalisa90 avatar Mar 05 '19 22:03 Monalisa90

When I first tried to generate a pdf I got the message on "xelatex not found on PATH" and followed the provided instructions, but it didn't work. But once I completely restarted jupyter, it worked just fine. Perhaps we just need to update the relevant docs / error message to state that a restart is necessary. @lordgrenville / @ProsperousHeart can either of you confirm that a restart of the jupyter notebook resolved this issue?

@ProsperousHeart can you change the title to something like "Unable to generate pdf (xelatex not found on PATH)" to better reflect the issue?

Thanks@

hansonap avatar Mar 07 '19 18:03 hansonap

nbconvert failed: xelatex not found on PATH

had this problem on ubuntu, fixed with sudo apt-get install texlive-xetex

jmsv avatar Apr 03 '19 12:04 jmsv

When I first tried to generate a pdf I got the message on "xelatex not found on PATH" and followed the provided instructions, but it didn't work. But once I completely restarted jupyter, it worked just fine. Perhaps we just need to update the relevant docs / error message to state that a restart is necessary. @lordgrenville / @ProsperousHeart can either of you confirm that a restart of the jupyter notebook resolved this issue?

@ProsperousHeart can you change the title to something like "Unable to generate pdf (xelatex not found on PATH)" to better reflect the issue?

Thanks@

I had the same issue.. restarted jupyter notebook, and checked if xelatex was in the path using: import os os.environ['PATH'].split(';') but it wasn't.

You need to quit jupyter notebook and open a new command prompt, then jupyter will find the newly added item to the PATH

abulhawa avatar Oct 09 '19 08:10 abulhawa

Since you're on windows, I recommend downloading and installing miktex. It should automatically add LaTeX to the system path. Check if MiKTeX is anywhere on you're system. You can type that latex is in your path by:

From the command line type:

c\> latex --version

If this spits out a version, then I don't know what your problem is.

If this doesn't find a version, but MikTeX is installed on your system (It should be searchable from the start menu), then try to add C:\Program Files\MiKTeX 2.9\miktex\bin\x64 to your path. (Check that that is indeed where MikTeX is installed).

Alternatively, you can install miktex using chocolatey, which is a package manager for windows. This is the easiest way to install LaTeX on windows in my opinion. Follow the linked instructions to install chocolatey using an admin powershell. Then use:

choco install MikTeX

from an admin powershell. Chocolatey will shim MikTeX into the path, so it will certainly work.

Installing miktex worked perfectly running Anaconda on Windows

kkairu avatar Jan 18 '20 23:01 kkairu

nbconvert failed: xelatex not found on PATH

had this problem on ubuntu, fixed with sudo apt-get install texlive-xetex

thank you! Solve the problem for me

KennethBenicio avatar Mar 17 '20 19:03 KennethBenicio

nbconvert failed: xelatex not found on PATH

had this problem on ubuntu, fixed with sudo apt-get install texlive-xetex

This worked for me!

vipulchakravarthy avatar Apr 12 '20 14:04 vipulchakravarthy

having this problem on MacOS Catalina. nbconvert failed: xelatex not found on PATH even after a full Tex install and total reboot.

lvwarren avatar Apr 27 '20 17:04 lvwarren

having this problem on MacOS Catalina. nbconvert failed: xelatex not found on PATH even after a full Tex install and total reboot.

Same problem for me. I have installed the full MacTex, added path variable for MacTex and restarted Jupyter. Nothing is working.

rsc2143 avatar May 20 '20 16:05 rsc2143

@rsc2143 Does xelatex command work from command line? If it does then the nbconvert conversion should be able to use it since it's doing a subprocess call. If not your PATH is missing the path to the xelatex binary. I don't have a MacOS so it's a little hard for me to test. On Ubuntu the package install updates the PATH correctly, but I've had issues with brew installs on macs in the past not updating PATHs correctly.

MSeal avatar May 22 '20 17:05 MSeal

I'm having the same issue on MacOS. I download the jupyter notebook as a .tex but now I can't convert it into a PDF, using LaTexIt or TeXShop.

rakhira avatar Jul 01 '20 18:07 rakhira

Latex conversion of Python notebooks is a disaster. I've abandoned it entirely for html5.

lvwarren avatar Jul 01 '20 20:07 lvwarren

Unfortunately there's very little maintenance of LaTeX in nbconvert -- LaTeX conversions are complex beast and there's not someone keeping it fed over time for all the many edge cases and build tool changes.

There is a new webpdf conversion using chromium to generate PDF files coming in 6.0, which trades off some of the flexibility of xelatex / pandoc for consistency with web renderings (and a new optional dependency).

The maintainers are trying to get the last of issues resolved for a final release our of alpha for 6.0. There's just not many of us with a lot of free time to contribute.

MSeal avatar Jul 01 '20 22:07 MSeal

I was thinking about this problem recently and realized that you should be able to point directly to LaTeX instead of relying on it being in the path. To so this, just add:

c.PDFExporter.latex_command = ['/path/to/xelatex', '{filename}', '-quiet']

to your jupyter_notebook_config.py, and jupyter_nbconvert_config.py files. (restarting your jupyter server after of course).

t-makaro avatar Jul 23 '20 01:07 t-makaro

When I first tried to generate a pdf I got the message on "xelatex not found on PATH" and followed the provided instructions, but it didn't work. But once I completely restarted jupyter, it worked just fine. Perhaps we just need to update the relevant docs / error message to state that a restart is necessary. @lordgrenville / @ProsperousHeart can either of you confirm that a restart of the jupyter notebook resolved this issue?

@ProsperousHeart can you change the title to something like "Unable to generate pdf (xelatex not found on PATH)" to better reflect the issue?

Thanks@

Thank you. solved the problem for me. I just had to reinstall jupyter in the environment -> conda install jupyter

FranciscoCarmonaFarfan avatar Aug 16 '20 06:08 FranciscoCarmonaFarfan

I had this issue on MacOS and I just had to set the PATH and it worked (at least by using nbconvert from the command line). Found the path in TeXShop which was /Library/TeX/texbin so if anyone wants to give it a shot

export PATH=$PATH=/Library/TeX/texbin
python -m jupyter nbconvert --to pdf <file>

sakshampuri avatar Aug 27 '20 10:08 sakshampuri

I had this issue on MacOS and I just had to set the PATH and it worked (at least by using nbconvert from the command line). Found the path in TeXShop which was /Library/TeX/texbin so if anyone wants to give it a shot

export PATH=$PATH=/Library/TeX/texbin
python -m jupyter nbconvert --to pdf <file>

Thanks! It helps me on MacOS Catalina. Just a small correction: export PATH=$PATH:/Library/TeX/texbin.

carlee0 avatar Oct 01 '20 07:10 carlee0

Add "env": {"PATH":"$PATH"} to your kernel.json, for me that was in /opt/anaconda3/share/jupyter/kernels/python3/kernel.json.

JupyterLab or Anaconda seems to override the system PATH by default, if you set this then the PATH will be the same in JupyterLab and in your shell, so if you have anything custom installed like xelatex, it will show up in JupyterLab.

hnryjmes avatar Oct 29 '20 12:10 hnryjmes

nbconvert failed: xelatex not found on PATH

had this problem on ubuntu, fixed with sudo apt-get install texlive-xetex

I have installed it and I can find it:

xelatex: /usr/bin/xelatex /usr/share/man/man1/xelatex.1.gz

But I run into the issue. Does anyone have any idea?

[NbConvertApp] PDF successfully created
[NbConvertApp] Writing 323403 bytes to /tmp/tmp-73003IQh2QeTIPD9A.pdf

	at a.executeCommand (/home/wang/.vscode/extensions/ms-toolsai.jupyter-2020.12.414227025/out/client/extension.js:1:448888)
	at processTicksAndRejections (internal/process/task_queues.js:94:5)
	at async a.export (/home/wang/.vscode/extensions/ms-toolsai.jupyter-2020.12.414227025/out/client/extension.js:49:254436)
	at async _.exportToFormat (/home/wang/.vscode/extensions/ms-toolsai.jupyter-2020.12.414227025/out/client/extension.js:49:252696)
	at async _.performExport (/home/wang/.vscode/extensions/ms-toolsai.jupyter-2020.12.414227025/out/client/extension.js:49:251809)
	at async _.export (/home/wang/.vscode/extensions/ms-toolsai.jupyter-2020.12.414227025/out/client/extension.js:49:251323)
	at async m.export (/home/wang/.vscode/extensions/ms-toolsai.jupyter-2020.12.414227025/out/client/extension.js:32:265964)]
Error 2020-12-15 20:38:41: 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.

And I cannot convert into HTML,

[NbConvertApp]     template_path: .
[NbConvertApp] Writing 2306326 bytes to /tmp/tmp-73003W4pDsmFl1Kfe.html

	at a.executeCommand (/home/wang/.vscode/extensions/ms-toolsai.jupyter-2020.12.414227025/out/client/extension.js:1:448888)
	at processTicksAndRejections (internal/process/task_queues.js:94:5)
	at async a.export (/home/wang/.vscode/extensions/ms-toolsai.jupyter-2020.12.414227025/out/client/extension.js:49:253800)
	at async _.exportToFormat (/home/wang/.vscode/extensions/ms-toolsai.jupyter-2020.12.414227025/out/client/extension.js:49:252766)
	at async _.performExport (/home/wang/.vscode/extensions/ms-toolsai.jupyter-2020.12.414227025/out/client/extension.js:49:251809)
	at async _.export (/home/wang/.vscode/extensions/ms-toolsai.jupyter-2020.12.414227025/out/client/extension.js:49:251323)
	at async m.export (/home/wang/.vscode/extensions/ms-toolsai.jupyter-2020.12.414227025/out/client/extension.js:32:265964)]

wangzhankun avatar Dec 15 '20 12:12 wangzhankun

steps to fix in windows: 0. install Miktex and pandoc from official website, launch any tex file and generate pdf, which will guide you install all the packages. https://github.com/jupyter/nbconvert/issues/799#issuecomment-469877993

  1. generate config if not yet done (check %userprofile%\.jupyter\): jupyter lab/notebook --generate-config
  2. add this to the end of config.py c.PDFExporter.latex_command = ['/path/to/xelatex', '{filename}', '-quiet'] https://github.com/jupyter/nbconvert/issues/799#issuecomment-662780585
  3. and add this to the end of config.py c.PDFExporter. bib_command = ['/path/to/bibtex', '{filename}']. /path/to/bibtex is path of the executables, check the file location of the xelatex/bibtex to see exact location and replace in the command
  4. launch or restart jupyter notebook/lab this helped me fixed pdf generation issue.

dcslin avatar Mar 23 '21 15:03 dcslin

python -m jupyter nbconvert --to pdf

Was having an issue with Mac as well but this solved it, thanks!

darienlizano avatar May 21 '21 01:05 darienlizano

nbconvert failed: xelatex not found on PATH

had this problem on ubuntu, fixed with sudo apt-get install texlive-xetex

It worked. Thank you 🙏

manashmandal avatar Oct 22 '21 06:10 manashmandal

Went through all the steps, here's what worked for me on mac OS Monterey :

Install Home-brew : /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

Install pandoc : brew install pandoc

Install texlive-xetex : brew install texlive-xetex

Install pyppeteer : conda install -c conda-forge pyppeteer

Install Chromium : jupyter nbconvert --to webpdf --allow-chromium-download Untitled.ipynb

The Chromium part is little complex, I followed this link below - https://stackoverflow.com/questions/66514334/nbconvert-use-allow-chromium-download :

  • You should run from inside notebook's directory (by doing cd folder name and make sure you have Untitled.ipynb file in there with any content - content doesn't matter)
  • "Untitled" is the name of your notebook
  • After manually downloading chromium once, you can download as pdf from Jupyter

Chromium installation would happen only once, then you can use the File > Download as > PDF via HTML

So, now I am able to download; this is still messing out Raw cells but Markdown and Code cells are coming out fine in PDF that is been downloaded.

navneet-kumar-92 avatar Jan 09 '22 15:01 navneet-kumar-92

This issue has been mentioned on Jupyter Community Forum. There might be relevant details there:

https://discourse.jupyter.org/t/inkscape-error-when-converting-julia-notebook-to-pdf/13112/5

meeseeksmachine avatar Feb 21 '22 22:02 meeseeksmachine

I think this video will work for you. https://youtu.be/3RkFjA3lcB0

rcsoul avatar May 25 '22 17:05 rcsoul