简体   繁体   English

Jupyter notebook 权限错误

[英]Jupyter notebook permission error

I'm having some issues with opening Jupyter.我在打开 Jupyter 时遇到了一些问题。 I just installed Anaconda, but got the same error as before when I try to write "Jupyter notebook" in terminal.我刚刚安装了 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 :)由于我对这一切几乎一无所知,我需要一些帮助:)

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 用户工作

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

sudo chown -R `whoami`:staff ~/Library/Jupyter
  1. You may be working under the initial installers userid您可能正在使用初始安装程序用户 ID
  2. Go to Ananconda prompt and change directory with these 2 commands >cd.. and >cd yourusername .转到 Ananconda 提示符并使用这 2 个命令>cd..>cd yourusername更改目录。
  3. Use the command使用命令

    jupyter notebook

This worked for me.这对我有用。

The permission error may be due to directory is not in 777 mode.权限错误可能是由于目录不是 777 模式。 Please follow below command, it works for me:请按照以下命令操作,它适用于我:

sudo chmod -R 777 .local

You can change ".local" directory according to error occurred in your directory.您可以根据目录中发生的错误更改“.local”目录。

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 jupyter and It was sovled.我使用 PyCharm 安装 jupyter,所以只需更新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 它只是打印已安装但某些依赖模块没有更新

As a root execute:作为根执行:

sudo nano  ~/.bashrc

Add at the begining of the file:在文件开头添加:

 export XDG_RUNTIME_DIR="" 

Press Ctrl-o to write file and Ctrl+x to 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 笔记本并使当前用户(例如 joe)拥有文件夹中的所有内容(以及文件夹本身):

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

pip install notebook --user

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

I ran "whereis jupyter" to get the following output:我运行“whereis jupyter”得到以下输出:

/snap/bin/jupyter /snap/bin/jupyter.ipython /snap/bin/jupyter.nbconvert /snap/bin/jupyter /snap/bin/jupyter.ipython /snap/bin/jupyter.nbconvert

Then I ran the following command:然后我运行以下命令:

sudo chmod -R 755 /snap/bin/jupyter sudo chmod -R 755 /snap/bin/jupyter

Previously, I was trying to set the permission for the folder where I was opening a Jupyter notebook.以前,我试图为打开 Jupyter 笔记本的文件夹设置权限。 It did not work.那没起效。 It seems that the permission needs to be set for the folder where jupyter is located.看来jupyter所在的文件夹需要设置权限。

I was having the same problem!我遇到了同样的问题! Then I opened a terminal and changed to the directory folder that I was trying to work and opened the jupyter notebook and that worked for me.然后我打开一个终端并切换到我试图工作的目录文件夹并打开 jupyter notebook 并且对我有用。 My folder was in the /media folder.我的文件夹在 /media 文件夹中。

Paulo保罗

I ended up opening up my Jupyter notebook using sudo in my terminal of my Mac.我最终在我的 Mac 终端中使用 sudo 打开了我的 Jupyter 笔记本。

sudo jupyter-notebook --allow-root

I tried the other solutions proposed in this post and this was the one that worked for me in solving my persistent permission errors for reading/saving files from my Jupyter notebook.我尝试了这篇文章中提出的其他解决方案,这是解决我从 Jupyter 笔记本读取/保存文件的持久性权限错误的解决方案。 Granted this approach might raise some security concerns, so I encourage others to provide critique if they find any potential fault in it.当然,这种方法可能会引发一些安全问题,所以我鼓励其他人在发现任何潜在错误时提出批评。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM