服务器端jupyter notebook 服务挂了,报错 502 bad gateway, KeyError: 'runtime_dir' PermissionError: [Errno 13]

登录jupyter时报错:

服务器端jupyter notebook 服务挂了,报错 502 bad gateway, KeyError: 'runtime_dir' PermissionError: [Errno 13]_第1张图片

正常情况重启jupyter不间断服务即可:

nohup jupyter notebook &

 

但重启时报错如下:

Traceback (most recent call last):
  File "/usr/local/anaconda3/lib/python3.7/site-packages/traitlets/traitlets.py", line 528, 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 "/usr/local/anaconda3/bin/jupyter-notebook", line 11, in 
    sys.exit(main())
  File "/usr/local/anaconda3/lib/python3.7/site-packages/jupyter_core/application.py", line 266, in launch_instance
    return super(JupyterApp, cls).launch_instance(argv=argv, **kwargs)
  File "/usr/local/anaconda3/lib/python3.7/site-packages/traitlets/config/application.py", line 658, in launch_instance
    app.start()
  File "/usr/local/anaconda3/lib/python3.7/site-packages/notebook/notebookapp.py", line 1758, in start
    super(NotebookApp, self).start()
  File "/usr/local/anaconda3/lib/python3.7/site-packages/jupyter_core/application.py", line 255, in start
    self.subapp.start()
  File "/usr/local/anaconda3/lib/python3.7/site-packages/notebook/notebookapp.py", line 488, in start
    serverinfo_list = list(list_running_servers(self.runtime_dir))
  File "/usr/local/anaconda3/lib/python3.7/site-packages/traitlets/traitlets.py", line 556, in __get__
    return self.get(obj, cls)
  File "/usr/local/anaconda3/lib/python3.7/site-packages/traitlets/traitlets.py", line 535, in get
    value = self._validate(obj, dynamic_default())
  File "/usr/local/anaconda3/lib/python3.7/site-packages/jupyter_core/application.py", line 99, in _runtime_dir_default
    ensure_dir_exists(rd, mode=0o700)
  File "/usr/local/anaconda3/lib/python3.7/site-packages/jupyter_core/utils/__init__.py", line 13, in ensure_dir_exists
    os.makedirs(path, mode=mode)
  File "/usr/local/anaconda3/lib/python3.7/os.py", line 221, in makedirs
    mkdir(name, mode)
PermissionError: [Errno 13] Permission denied: '/run/user/0/jupyter'

解决方案:

sudo -i
cd /run/user/0/
chmod -R a+rX jupyter/

即可,

然后正常启动不间断jupyter服务:

nohup jupyter notebook &

 

你可能感兴趣的:(linux)