nbconvert
nbconvert copied to clipboard
nbconvert `--user` install fails to find templates
A completely default macOS --user install of Nbconvert fails with the following error:
$ python3 -m jupyter nbconvert foo.ipynb --to html
...
ValueError: No template sub-directory with name 'lab' found in the following paths:
/Users/mbr110/Library/Jupyter
/usr/local/opt/[email protected]/Frameworks/Python.framework/Versions/3.9/share/jupyter
/usr/local/share/jupyter
/usr/share/jupyter
I get the same error using Homebrew or Python.org Python.
Steps to reproduce:
- Make new user
- Put user bin directory on path:
export PATH="$PATH:$HOME/Library/Python/3.9/bin"(needed for Jupyter subcommands to work); python3 -m pip install --user nbconverttouch foo.ipynbpython3 -m jupyter nbconvert foo.ipynb --to html
This appears to be because Nbconvert is not looking in the default template install directory after a user install, which is (in my case, Python 3.9): ~/Library/Python/3.9/share/jupyter
https://stackoverflow.com/a/68294070
As the SO answer suggests, I can fix the error with a prior:
mkdir -p ~/Library/Jupyter
ln -sf ~/Library/Python/3.9/share/jupyter/nbconvert ~/Library/Jupyter/nbconvert
I believe this is a bug, and that the macOS default user install directory should also be on the search path. Do y'all agree?
It's not really a macOS-only bug. I see this in pyenv-installed environments on Linux, too.
Cf. e.g. https://github.com/sagemath/sage/pull/36256#issuecomment-1721871688