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

wwodge7n  于 2022-11-08  发布在  其他
关注(0)|答案(4)|浏览(655)

尝试在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
6rqinv9w

6rqinv9w1#

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

我不得不简单地设置IP/端口参数。这个问题很可能是因为它以前试图分配的默认IP/端口已经被占用了!

qnyhuwrf

qnyhuwrf2#

在远程虚拟机中,我通过以下方法解决了该问题

$ 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笔记本电脑:

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

(将0.0.0.0替换为your_vm_ip

1tuwyuhd

1tuwyuhd3#

这里有一个永久的解决办法。
1.为Jupyter创建一个配置文件,在终端中输入:jupyter notebook --generate-config
1.最后一个命令将在**/home/USER/.jupyter/jupyter_notebook_config.py中创建文件
1.打开文件
jupyter_notebook_config.py并编辑变量c.NotebookApp.ip**,如下所示:
# c.NotebookApp.ip = 'localhost'
c.NotebookApp.ip = '127.0.0.1'
1.在终端中输入:jupyter notebook
备注:有时需要先chmod才能授予权限,文件

2ic8powd

2ic8powd4#

如果您已经尝试了几个端口(使用--port XXXX),但都不起作用:
检查/etc/hosts/中的localhost条目是否未设置为127.0.0.1以外的值。

相关问题