nbconvert: Permission denied problem with nbconvert
I have a conda installation of jupyter and, after a recent update, my ability to export and otherwise convert jupyter notebooks has been curtailed. For instance, I’m having the following problem at the command line:
guardian@titan:scratch$ jupyter nbconvert --to html mynotebook.ipynb
Traceback (most recent call last):
File "/Users/guardian/miniconda3/bin/jupyter-nbconvert", line 7, in <module>
from nbconvert.nbconvertapp import main
File "/Users/guardian/miniconda3/lib/python3.7/site-packages/nbconvert/nbconvertapp.py", line 140, in <module>
class NbConvertApp(JupyterApp):
File "/Users/guardian/miniconda3/lib/python3.7/site-packages/nbconvert/nbconvertapp.py", line 225, in NbConvertApp
""".format(formats=get_export_names()))
File "/Users/guardian/miniconda3/lib/python3.7/site-packages/nbconvert/exporters/base.py", line 141, in get_export_names
e = get_exporter(exporter_name)(config=config)
File "/Users/guardian/miniconda3/lib/python3.7/site-packages/nbconvert/exporters/base.py", line 102, in get_exporter
if getattr(exporter(config=config), 'enabled', True):
File "/Users/guardian/miniconda3/lib/python3.7/site-packages/nbconvert/exporters/templateexporter.py", line 328, in __init__
super().__init__(config=config, **kw)
File "/Users/guardian/miniconda3/lib/python3.7/site-packages/nbconvert/exporters/exporter.py", line 114, in __init__
self._init_preprocessors()
File "/Users/guardian/miniconda3/lib/python3.7/site-packages/nbconvert/exporters/templateexporter.py", line 494, in _init_preprocessors
conf = self._get_conf()
File "/Users/guardian/miniconda3/lib/python3.7/site-packages/nbconvert/exporters/templateexporter.py", line 512, in _get_conf
if conf_path.exists():
File "/Users/guardian/miniconda3/lib/python3.7/pathlib.py", line 1361, in exists
self.stat()
File "/Users/guardian/miniconda3/lib/python3.7/pathlib.py", line 1183, in stat
return self._accessor.stat(self)
PermissionError: [Errno 13] Permission denied: '/usr/local/share/jupyter/nbconvert/templates/conf.json'
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Reactions: 2
- Comments: 30 (9 by maintainers)
Commits related to this issue
- Do not attempt to create additional template paths. Fixes #1430 Many users are reporting that nbconvert 6.x has permission errors when queried or converting files. These seem to arise when nbconvert... — committed to jasongrout/nbconvert by jasongrout 3 years ago
- Do not attempt to create additional template paths. (#1646) * Do not attempt to create additional template paths. Fixes #1430 Many users are reporting that nbconvert 6.x has permission errors w... — committed to jupyter/nbconvert by jasongrout 3 years ago
- Bump of nbconvert to version 6.4.0. The previous version, nbconvert 6.1.0, could cause permission denied errors when run in a shared environment. See https://github.com/jupyter/nbconvert/issues/1430 .... — committed to sara-nl/easybuild-easyconfigs by deleted user 2 years ago
This Permission error is caused due to the version of nbconvert. nbconvert 6.1.0 was the reason for this error. I have downgraded the nbconvert to 5.6.1 and it fixed the issue for me. I no longer face the Permission error any more while trying to open .ipynb files.
I thing the solution is to change the permissions on recursively
/usr/local/share/jupyter/
to 0755 and the permissions of the files within the nbconvert folder to 0644 and the executables to 0655.This feels pretty ugly, but will probably solve your problem.
You can use the find command to do this:
I administer jupyterhub/lab for two separate institutions, and this has bit us both places. As @k-nayak helpfully points out, the workaround is to downgrade to 5.6.1 (thanks!), but I would recommend this issue re-open as it’s a significant break for multi-user applications of this.
If there are other people who still hit this with the 6.2 release - in our case this happens when we’re converting some notebooks in our CI which runs in a sandbox and can’t access
/usr
. We fixed it with the patch below.Investigating this, nbconvert 5.6 stores its templates in site-packages:
while nbconvert 6.1 stores its templates in the share directory:
Plenty of Jupyter packages store data in the
share/jupyter
directory (e.g., JupyterLab, Jupyter Notebook, IPython kernel spec, etc.). Putting files there is not out of the ordinary at all. The files in thatshare/jupyter
directory should be readable to function.If you install, for example, JupyterLab, Jupyter Notebook, ipywidgets, etc. in the same way, are their
share/jupyter
files also unreadable?Hi @gideonsimpson , I found that if I install jupyterhub and jupyterlab using conda with root, the permission of
/usr/local/share/jupyter/nbconvert/templates
will be 0700, and other users without root will not be able to writeconf.json
into this dir. I think this is because nbconvert was not designed for multi-user initially like jupyterhub. Will there be a plan to add multi-user support for nbconvert?After reviewing the two PRs #1028 and #1056, I think we can just remove this code. I’ve done this in https://github.com/jupyter/nbconvert/pull/1646, ready for review.
@jasongrout it seems that the culprit is this snippet:
https://github.com/jupyter/nbconvert/blob/4607ed2078f38a63d055e76307d9f66f32e8a5fd/nbconvert/exporters/templateexporter.py#L550-L555
and more specifically the call to
ensure_dir_exists
. It causes the creation of an emptytemplates
folder for all levels ofadditional_paths
some of which may be system libraries.I have this problem as well and downgrading worked but is never the best solution
what are the permissions on the
/usr/local/share/jupyter/nbconvert/templates/
directory?try:
ls -alh /usr/local/share/jupyter/nbconvert/templates/
andls -alh /usr/local/share/jupyter/nbconvert/templates/conf.json