当前位置: 代码迷 >> 综合 >> jupyter notebook, KeyError: 'runtime_dir',[Errno 13] Permission denied
  详细解决方案

jupyter notebook, KeyError: 'runtime_dir',[Errno 13] Permission denied

热度:110   发布时间:2023-09-24 04:36:13.0

在用实验室的服务器运行jupyter notebook 的时候,报了如下错。

Traceback (most recent call last):File "/Users/JDMac/anaconda3/lib/python3.5/site-packages/traitlets/traitlets.py", line 501, in getvalue = 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_instancereturn 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_instanceapp.initialize(argv)File "<decorator-gen-7>", line 2, in initializeFile "/Users/JDMac/anaconda3/lib/python3.5/site-packages/traitlets/config/application.py", line 74, in catch_config_errorreturn method(app, *args, **kwargs)File "/Users/JDMac/anaconda3/lib/python3.5/site-packages/notebook/notebookapp.py", line 1021, in initializeself.init_configurables()File "/Users/JDMac/anaconda3/lib/python3.5/site-packages/notebook/notebookapp.py", line 815, in init_configurablesconnection_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 getvalue = self._validate(obj, dynamic_default())File "/Users/JDMac/anaconda3/lib/python3.5/site-packages/jupyter_core/application.py", line 99, in _runtime_dir_defaultensure_dir_exists(rd, mode=0o700)File "/Users/JDMac/anaconda3/lib/python3.5/site-packages/ipython_genutils/path.py", line 167, in ensure_dir_existsos.makedirs(path, mode=mode)File "/Users/JDMac/anaconda3/lib/python3.5/os.py", line 241, in makedirsmkdir(name, mode)
PermissionError: [Errno 13] Permission denied: '/Users/JDMac/Library/Jupyter/runtime'

 

jupyter notebook, KeyError: 'runtime_dir',[Errno 13] Permission denied

 

这个截图是我报的错。

我用的是实验室的服务器,多人共用。

上面显示的是我的运行目录指向了1007的jupyter,而我在服务器的编号是1019,于是我在终端上输入了

export XDG_RUNTIME_DIR = /run/user/1019

就可以运行了。

在此感谢刘大佬的帮助。

 

PS:如果是个人使用的Ubuntu啊什么的,直接在jupyter notebook前面加 sudo就行了。

 

 

后续还遇到了failed to write server-info的问题,也就是打开notebook后,想要对创建的notebook进行保存,但是页面右上角出现了红色的方框,上面显示kernel error。

根据终端的提示,我把permission denied 显示的那个runtime 文件里面的文件权限改成自己可以写入读取之后就好了。

具体命令可参考

chown user:user filename

chmod 777 filename

参考问答:https://stackoverflow.com/questions/35878178/jupyter-notebook-permission-error

  相关解决方案