在virtualenv中从jupyter笔记本生成sphinx文档时遇到“笔记本错误:PermissionError”

问题描述 投票:1回答:1

我有一个笔记本,无论是否带有virtualenv,它都可以以root身份生成,但是以标准用户身份生成时会失败。

$ make html
reading sources... [100%] notebooks/demo_short                                                                                                                                                
Notebook error:
PermissionError in notebooks/demo_short.ipynb:
[Errno 13] Permission denied: '/usr/local/share/jupyter/nbconvert/templates/rst.tpl'
Makefile:19: recipe for target 'html' failed

$ sphinx-build -M html "." "_build" -v
[...]
  File "/home/with_home/p3/lib/python3.6/site-packages/jinja2/loaders.py", line 171, in get_source
    f = open_if_exists(filename)
  File "/home/with_home/p3/lib/python3.6/site-packages/jinja2/utils.py", line 154, in open_if_exists
    return open(filename, mode)
PermissionError: [Errno 13] Permission denied: '/usr/local/share/jupyter/nbconvert/templates/rst.tpl'

During handling of the above exception, another exception occurred:

[...]
  File "/home/with_home/p3/lib/python3.6/site-packages/docutils/readers/__init__.py", line 77, in parse
    self.parser.parse(self.input, document)
  File "/home/with_home/p3/lib/python3.6/site-packages/nbsphinx.py", line 869, in parse
    str(e))
nbsphinx.NotebookError: PermissionError in notebooks/demo_short.ipynb:
[Errno 13] Permission denied: '/usr/local/share/jupyter/nbconvert/templates/rst.tpl'

Notebook error:
PermissionError in notebooks/demo_short.ipynb:
[Errno 13] Permission denied: '/usr/local/share/jupyter/nbconvert/templates/rst.tpl'

我认为指示的路径是错误的,因为它应该指向我的virtualenv中的某个位置,但我不确定。

如果有帮助,我尝试了virtualenv中的命令jupyter nbconvert notebooks/demo_short.ipynb。使用root可以,但是对于标准用户,我可以:

[...]
  File "/home/with_home/.local/lib/python3.6/site-packages/nbconvert/exporters/templateexporter.py", line 78, in get_source
    return self.loader.get_source(environment, template)
  File "/usr/lib/python3/dist-packages/jinja2/loaders.py", line 171, in get_source
    f = open_if_exists(filename)
  File "/usr/lib/python3/dist-packages/jinja2/utils.py", line 154, in open_if_exists
    return open(filename, mode)
PermissionError: [Errno 13] Permission denied: '/usr/local/share/jupyter/nbconvert/templates/html/full.tpl'

欢迎使用任何指针,因为我不知道pb是来自狮身人面像,jupyter,nbconvert,nbsphinx还是模板。

templates jupyter-notebook virtualenv file-permissions python-sphinx
1个回答
0
投票

您确定nbconvert在/ usr / local / share / jupyter / nbconvert下吗?我也遇到过同样的问题。删除/ usr / local / share / jupyter /就可以了。

© www.soinside.com 2019 - 2024. All rights reserved.