Ipython Notebook仅以root身份运行

nit*_*shr 5 root ipython ipython-notebook jupyter

我试图在iPython中导入一个笔记本(更新后的Jupyter).但由于某种原因,我只能以root用户身份运行才能导入任何笔记本.否则,我收到所有笔记本的以下错误.

加载此笔记本时发生未知错误.此版本可以加载v4或更早版本的笔记本电脑.有关详细信息,请参阅服

iPython3笔记本能够加载笔记本电脑.我有什么办法可以解决这个问题吗?

[W 23:04:29.100 NotebookApp] 404 GET /static/components/MathJax/config/Safe.js?rev=2.5.3 (127.0.0.1) 40.67ms referer=http://localhost:8889/notebooks/Challenges/German%20Credit%20Dataset%20Classification%20-%20Challenge%201/GermanCreditCardClassification.ipynb
[E 23:04:29.377 NotebookApp] Unhandled error in API request
    Traceback (most recent call last):
      File "/usr/local/lib/python2.7/dist-packages/notebook/base/handlers.py", line 436, in wrapper
        result = yield gen.maybe_future(method(self, *args, **kwargs))
      File "/usr/local/lib/python2.7/dist-packages/tornado/gen.py", line 870, in run
        value = future.result()
      File "/usr/local/lib/python2.7/dist-packages/tornado/concurrent.py", line 215, in result
        raise_exc_info(self._exc_info)
      File "/usr/local/lib/python2.7/dist-packages/tornado/gen.py", line 230, in wrapper
        yielded = next(result)
      File "/usr/local/lib/python2.7/dist-packages/notebook/services/contents/handlers.py", line 129, in get
        path=path, type=type, format=format, content=content,
      File "/usr/local/lib/python2.7/dist-packages/notebook/services/contents/filemanager.py", line 348, in get
        model = self._notebook_model(path, content=content)
      File "/usr/local/lib/python2.7/dist-packages/notebook/services/contents/filemanager.py", line 308, in _notebook_model
        self.mark_trusted_cells(nb, path)
      File "/usr/local/lib/python2.7/dist-packages/notebook/services/contents/manager.py", line 447, in mark_trusted_cells
        trusted = self.notary.check_signature(nb)
      File "/usr/local/lib/python2.7/dist-packages/nbformat/sign.py", line 220, in check_signature
        if self.db is None:
      File "/usr/local/lib/python2.7/dist-packages/traitlets/traitlets.py", line 439, in __get__
        value = self._validate(obj, dynamic_default())
      File "/usr/local/lib/python2.7/dist-packages/nbformat/sign.py", line 126, in _db_default
        db = sqlite3.connect(self.db_file, **kwargs)
    OperationalError: unable to open database file
[E 23:04:29.389 NotebookApp] {
      "Accept-Language": "en-US,en;q=0.8", 
      "Accept-Encoding": "gzip, deflate, sdch", 
      "Connection": "keep-alive", 
      "Accept": "application/json, text/javascript, */*; q=0.01", 
      "User-Agent": "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/47.0.2526.73 Safari/537.36", 
      "Dnt": "1", 
      "Host": "localhost:8889", 
      "X-Requested-With": "XMLHttpRequest", 
      "Referer": "http://localhost:8889/notebooks/Challenges/German%20Credit%20Dataset%20Classification%20-%20Challenge%201/GermanCreditCardClassification.ipynb"
    }
[E 23:04:29.390 NotebookApp] 500 GET /api/contents/Challenges/German%20Credit%20Dataset%20Classification%20-%20Challenge%201/GermanCreditCardClassification.ipynb?type=notebook&_=1449266668869 (127.0.0.1) 134.27ms referer=http://localhost:8889/notebooks/Challenges/German%20Credit%20Dataset%20Classification%20-%20Challenge%201/GermanCreditCardClassification.ipynb
Run Code Online (Sandbox Code Playgroud)

Ipython详细信息服务器信息:

You are using Jupyter notebook.

The version of the notebook server is 4.0.2 and is running on:
Python 2.7.6 (default, Jun 22 2015, 17:58:13) 
[GCC 4.8.2]

Current Kernel Information:

unable to contact kernel
Run Code Online (Sandbox Code Playgroud)

操作系统:在3.13.0-37-generic Kernel上运行的Linux Mint x64

答: KT.的解决方案有效.我认为我第一次以root身份运行Jupyter,导致KT提到的非root用户无法访问这些文件.

KT.*_*KT. 5

好吧,让我在这里猜测一下。

当你ipython notebook第一次跑步时,它在下面root。因此,Jupyter 使用的一些文件从一开始就被创建为 root 拥有的文件。现在,每当您以非 root 用户身份运行 Jupyter 时,他都会无法写入这些文件,从而导致您看到的错误,这并不奇怪。

在您在日志中看到的特定情况下,Jupyter 在写入nbsignatures.dbSQLite 数据库时出现问题。该文件应位于 Jupyter 中DATA_DIR,通常类似于~/.local/share/jupyter.

如果您没有此目录,您可以通过运行ipython并执行以下操作来找到它,例如:

In [1]: from jupyter_core.application import JupyterApp
In [2]: JupyterApp().data_dir
Out[2]: u'/home/ubuntu/.local/share/jupyter'
Run Code Online (Sandbox Code Playgroud)

您现在需要做的是确保该目录中的所有内容都归正确的用户所有,而不是 root 用户。这可能意味着做类似的事情

# chown -R <yourusername>.<yourusername> ~/.local/share/jupyter
Run Code Online (Sandbox Code Playgroud)

作为根。