OSError:[Errno 99]无法分配请求的地址

时间:2018-05-16 15:22:31

标签: centos anaconda jupyter-notebook jupyter

尝试在CentOS 7上运行jupyter notebook。它返回:

OSError: [Errno 99] Cannot assign requested address

堆栈跟踪:

[user@desktop ~]$ jupyter notebook
Traceback (most recent call last):
  File "/home/use/anaconda3/bin/jupyter-notebook", line 6, in <module>
    sys.exit(notebook.notebookapp.main())
  File "/home/user/anaconda3/lib/python3.6/site-packages/jupyter_core/application.py", line 267, in launch_instance
    return super(JupyterApp, cls).launch_instance(argv=argv, **kwargs)
  File "/home/user/anaconda3/lib/python3.6/site-packages/traitlets/config/application.py", line 657, in launch_instance
    app.initialize(argv)
  File "<decorator-gen-7>", line 2, in initialize
  File "/home/user/anaconda3/lib/python3.6/site-packages/traitlets/config/application.py", line 87, in catch_config_error
    return method(app, *args, **kwargs)
  File "/home/user/anaconda3/lib/python3.6/site-packages/notebook/notebookapp.py", line 1296, in initialize
    self.init_webapp()
  File "/home/user/anaconda3/lib/python3.6/site-packages/notebook/notebookapp.py", line 1120, in init_webapp
    self.http_server.listen(port, self.ip)
  File "/home/user/anaconda3/lib/python3.6/site-packages/tornado/tcpserver.py", line 142, in listen
    sockets = bind_sockets(port, address=address)
  File "/home/user/anaconda3/lib/python3.6/site-packages/tornado/netutil.py", line 197, in bind_sockets
    sock.bind(sockaddr)
OSError: [Errno 99] Cannot assign requested address

4 个答案:

答案 0 :(得分:1)

在远程虚拟机中,我通过

解决了这个问题
$ jupyter-notebook --ip=0.0.0.0 --port=8888
...
    
    Copy/paste this URL into your browser when you connect for the first time,
    to login with a token:
        http://0.0.0.0:8888/?token=1234567890abcdefghijklmnopqrstuvwxyz  (the token is for demo)
    
...

注意:不要分配具体的ip

然后我可以通过以下方式连接到 jupyter notebook:

http://your_vm_ip:8888/?token=1234567890abcdefghijklmnopqrstuvwxyz

(用 0.0.0.0 替换 your_vm_ip

enter image description here

答案 1 :(得分:0)

jupyter notebook --ip=127.0.0.1 --port=8888

我必须简单地设置ip / port params。问题可能是因为之前尝试分配的默认IP /端口已经被占用了!

答案 2 :(得分:0)

这是一个永久的解决方案。

  1. 为 Jupyter 创建一个配置文件,在终端输入:jupyter notebook --generate-config
  2. 最后一个命令将在 /home/USER/.jupyter/jupyter_notebook_config.py 中创建一个文件
  3. 打开文件 jupyter_notebook_config.py 并编辑变量 c.NotebookApp.ip 如下:
    # c.NotebookApp.ip = 'localhost'
    c.NotebookApp.ip = '127.0.0.1'
  4. 在终端输入:jupyter notebook

备注:有时需要先chmod授予权限,文件

答案 3 :(得分:0)

如果您已经尝试了多个端口(使用 --port XXXX),但都没有工作:

检查 localhost 中的 /etc/hosts/ 条目是否设置为除 127.0.0.1 以外的其他内容。