Nbconvert: Permission denied problem with nbconvert

Created on 30 Sep 2020  Â·  7Comments  Â·  Source: jupyter/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'
question

All 7 comments

what are the permissions on the /usr/local/share/jupyter/nbconvert/templates/ directory?

try: ls -alh /usr/local/share/jupyter/nbconvert/templates/ and ls -alh /usr/local/share/jupyter/nbconvert/templates/conf.json

I got permissions denied on both of them. What permissions should they have?

Or, alternatively, how can I set things for the user to use a local version?

This are the defaults created by the latest version of nbconvert

$ dir /usr/local/share/jupyter/nbconvert/templates 
total 0
drwx------  4 aaronciuffo  admin   128B Sep 29 19:56 .
drwxr-xr-x  3 aaronciuffo  admin    96B Sep 25 18:30 ..
drwx------  2 aaronciuffo  admin    64B Sep 29 19:56 html
drwx------  2 aaronciuffo  admin    64B Sep 29 19:56 latex

You should have a local copy somewhere in your path. Try jupyter --paths it should look something like this.

$ jupyter --paths                                                    (master) ✗
config:
    /Users/aaronciuffo/.jupyter
    /Users/aaronciuffo/.pyenv/versions/3.8.5/Python.framework/Versions/3.8/etc/jupyter 
    /usr/local/etc/jupyter
    /etc/jupyter
data:
    /Users/aaronciuffo/Library/Jupyter <- local user version
    /Users/aaronciuffo/.pyenv/versions/3.8.5/Python.framework/Versions/3.8/share/jupyter <- local user version
    /usr/local/share/jupyter
    /usr/share/jupyter
runtime:
    /Users/aaronciuffo/Library/Jupyter/runtime

afaik the local version was created when jupyter was installed by pip.

So the issue might be that I have two accounts on this machine, one that's admin, and the other on which I'm running the jupyter lab server. On the administrative account I have:

config:
    /Users/gideonsimpson/.jupyter
    /Users/gideonsimpson/miniconda3/etc/jupyter
    /usr/local/etc/jupyter
    /etc/jupyter
data:
    /Users/gideonsimpson/Library/Jupyter
    /Users/gideonsimpson/miniconda3/share/jupyter
    /usr/local/share/jupyter
    /usr/share/jupyter
runtime:
    /Users/gideonsimpson/Library/Jupyter/runtime

while on the jupyter account, I have:

config:
    /Users/guardian/.jupyter
    /Users/guardian/miniconda3/etc/jupyter
    /usr/local/etc/jupyter
    /etc/jupyter
data:
    /Users/guardian/Library/Jupyter
    /Users/guardian/miniconda3/share/jupyter
    /usr/local/share/jupyter
    /usr/share/jupyter
runtime:
    /Users/guardian/Library/Jupyter/runtime

But, the guardian account does not seem to have permissions to the /usr stuff:

gideonsimpson@machine:~$ ls -l /usr/local/share/jupyter/nbconvert/templates
total 0
drwx------  2 gideonsimpson  admin  64 Sep 16 15:31 html
drwx------  2 gideonsimpson  admin  64 Sep 16 15:31 latex

while

guardian@machine:~$ ls -l /usr/local/share/jupyter/nbconvert/template
ls: templates: Permission denied

I would not to give the guardian account root access, but am unsure of how to best handle this situation.

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:

# change the permissions on the directories to group, other read and execute
$ find ./ -type d -exec chmod go+rx {} \;

# change all the other files to group, other read
$ find ./ -type f -exec chmod  go+r {} \;

# change all the executables to group, other execute
$ find ./ -type f -perm -100 -exec chmod go+x {} \;

Yup, that did it.

Was this page helpful?
0 / 5 - 0 ratings