Python Jupyter 笔记本权限错误

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/35878178/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-19 17:06:34  来源:igfitidea点击:

Jupyter notebook permission error

pythonipythonanacondajupyter

提问by joddm

I'm having some issues with opening Jupyter. I just installed Anaconda, but got the same error as before when I try to write "Jupyter notebook" in terminal.

我在打开 Jupyter 时遇到了一些问题。我刚刚安装了 Anaconda,但是当我尝试在终端中编写“Jupyter notebook”时遇到了与以前相同的错误。

Johans-MBP:~ JDMac$ Jupyter notebook
Traceback (most recent call last):
  File "/Users/JDMac/anaconda3/lib/python3.5/site-packages/traitlets/traitlets.py", line 501, in get
    value = obj._trait_values[self.name]
KeyError: 'runtime_dir'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/JDMac/anaconda3/bin/jupyter-notebook", line 6, in <module>
    sys.exit(notebook.notebookapp.main())
  File "/Users/JDMac/anaconda3/lib/python3.5/site-packages/jupyter_core/application.py", line 267, in launch_instance
    return super(JupyterApp, cls).launch_instance(argv=argv, **kwargs)
  File "/Users/JDMac/anaconda3/lib/python3.5/site-packages/traitlets/config/application.py", line 588, in launch_instance
    app.initialize(argv)
  File "<decorator-gen-7>", line 2, in initialize
  File "/Users/JDMac/anaconda3/lib/python3.5/site-packages/traitlets/config/application.py", line 74, in catch_config_error
    return method(app, *args, **kwargs)
  File "/Users/JDMac/anaconda3/lib/python3.5/site-packages/notebook/notebookapp.py", line 1021, in initialize
    self.init_configurables()
  File "/Users/JDMac/anaconda3/lib/python3.5/site-packages/notebook/notebookapp.py", line 815, in init_configurables
    connection_dir=self.runtime_dir,
  File "/Users/JDMac/anaconda3/lib/python3.5/site-packages/traitlets/traitlets.py", line 529, in __get__
    return self.get(obj, cls)
  File "/Users/JDMac/anaconda3/lib/python3.5/site-packages/traitlets/traitlets.py", line 508, in get
    value = self._validate(obj, dynamic_default())
  File "/Users/JDMac/anaconda3/lib/python3.5/site-packages/jupyter_core/application.py", line 99, in _runtime_dir_default
    ensure_dir_exists(rd, mode=0o700)
  File "/Users/JDMac/anaconda3/lib/python3.5/site-packages/ipython_genutils/path.py", line 167, in ensure_dir_exists
    os.makedirs(path, mode=mode)
  File "/Users/JDMac/anaconda3/lib/python3.5/os.py", line 241, in makedirs
    mkdir(name, mode)
PermissionError: [Errno 13] Permission denied: '/Users/JDMac/Library/Jupyter/runtime'

As I'm close to clueless with all of this, I need some assistance over here :)

由于我对所有这些都几乎一无所知,因此我需要一些帮助:)

回答by Dejene

the solution is run the following command on the terminal as a normal user

解决方案是在终端上以普通用户身份运行以下命令

$ export XDG_RUNTIME_DIR="" then start the jupyter $jupyter notebook

$ export XDG_RUNTIME_DIR="" 然后启动jupyter $jupyter notebook

it will not work as root user

它不会以 root 用户身份工作

回答by joddm

If you are using macOS, this may help you:

如果您使用的是 macOS,这可能会帮助您:

sudo chown -R `whoami`:staff ~/Library/Jupyter

回答by SJ5823

  1. You may be working under the initial installers userid
  2. Go to Ananconda prompt and change directory with these 2 commands >cd..and >cd yourusername.
  3. Use the command

    jupyter notebook

  1. 您可能在初始安装程序用户 ID 下工作
  2. 转到 Ananconda 提示符并使用这 2 个命令>cd..>cd yourusername.
  3. 使用命令

    jupyter notebook

This worked for me.

这对我有用。

回答by Nisan Chhetri

The permission error may be due to directory is not in 777 mode. Please follow below command, it works for me:

权限错误可能是由于目录未处于 777 模式。请遵循以下命令,它对我有用:

sudo chmod -R 777 .local

You can change ".local" directory according to error occurred in your directory.

您可以根据目录中发生的错误更改“.local”目录。

回答by Harvey

As a root execute:

作为 root 执行:

sudo nano  ~/.bashrc

Add at the begining of the file:

在文件开头添加:

 export XDG_RUNTIME_DIR="" 

Press Ctrl-oto write file and Ctrl+xto exit.

Ctrl-o写入文件并Ctrl+x退出。

Now type:

现在输入:

source ~/.bashrc 

If that doesn't work uninstall Jupyter notebook and make the current user (joe for example) own everything inside the folder (and the folder itself):

如果这不起作用,请卸载 Jupyter Notebook 并使当前用户(例如 joe)拥有文件夹中的所有内容(以及文件夹本身):

sudo chown -R $joe:joe /home/joe/.jupyter

pip install notebook --user

回答by Igal L

What worked for me when I got the "Jupyter notebook permission error" in Win 10, was running the terminal in Administrator mode and writing "Jupyter notebook" from there.

当我在 Win 10 中遇到“Jupyter notebook 权限错误”时,对我有用的是在管理员模式下运行终端并从那里编写“Jupyter notebook”。

回答by lemmingxuan

I also met a similar problem like this:

我也遇到过类似这样的问题:

jupyter notebook
Traceback (most recent call last):
  File "c:\p\py353\lib\site-packages\traitlets\traitlets.py", line 528, in get
    value = obj._trait_values[self.name]
KeyError: 'log'
...

I install jupyter use PyCharm so just update jupyterand It was sovled.

我安装 jupyter 使用 PyCharm 所以只需更新jupyter它就被解决了。

command:

命令:

pip3 install --upgrade jupyter

if you use command below again: pip3 install jupyter it just print already installed but some dependent modules didn‘t update

如果你再次使用下面的命令:pip3 install jupyter 它只是打印已经安装 但一些依赖模块没有更新