jupyter / nbconvert

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

Pandoc on NixOS not found #841

Open drever opened 6 years ago

drever commented 6 years ago

When using nbconvert on NixOS it does not find pandoc. Pandoc is installed on the path:

$ pandoc --version
panda 1.19.2.1
Compiled with pandoc-types 1.17.0.5, texmath 0.9.4.1, skylighting 0.1.1.5

However, the python script doesn't find pandoc for some reason (gist):

 File "/nix/store/12qfbasij7rrzxjl0lqqg3lsy2jydi0d-python3-3.6.2-env/lib/python3.6/site-packages/nbconvert/utils/pandoc.py", line 76, in get_pandoc_version raise PandocMissing()
 nbconvert.utils.pandoc.PandocMissing: Pandoc wasn't found.

Calling nbconvert.utils.pandoc directly from python actually works.

Does anyone have an idea? NixOS is pretty restrictive when it comes to the exposition of binaries. They are only visible in environments where they are explicitly imported.

takluyver commented 6 years ago

It should be calling shutil.which('pandoc') - can you try that?

drever commented 6 years ago

It uses ipython_genutils.py3compat.which. Calling it from python directly works:

>>> from ipython_genutils.py3compat import which
>>> which('pandoc')
'/nix/store/g4fsbwfxm63nkip598mpni7q1anpj096-pandoc-1.19.2.1/bin/pandoc'

The python version is 3.6.2 and the nbconvert version is 5.2.1. Thanks for looking into this!

kfish610 commented 8 months ago

Unfortunately, I have the same issue; Python 3.9.5, pandoc 3.1.11, nbconvert 7.16.0. @drever did you ever figure this out? I know NixOS is pretty niche so I'm not holding my breath for someone to pick this up.

ivanov commented 8 months ago

@kfish610 sorry you're having trouble. Is this happening when running nbconvert as its own process, or when using nbconvert api in a Python process? Can you try running which pandoc at the shell and then adding that to your PATH variable prior to running nbconvert? PATH is what shutil.which uses to try to locate an executable, so we just need to figure out how to get that straightened out.