jupyter notebook -socket.gaierror: [Errno -5] No address associated with hostname錯誤及解決方式

jupyter notebook -socket.gaierror: [Errno -5] No address associated with hostname錯誤及解決方式

前言

這是筆者在Ubuntu 16.04下使用以下指令啟動jupyter notebook時所出現的錯誤:

jupyter notebook --allow-root --no-browser

錯誤訊息

Traceback (most recent call last):
File “/usr/local/lib/python3.5/dist-packages/traitlets/traitlets.py”, line 528, in get
value = obj._trait_values[self.name]
KeyError: ‘allow_remote_access’

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File “/usr/local/lib/python3.5/dist-packages/notebook/notebookapp.py”, line 864, in _default_allow_remote
addr = ipaddress.ip_address(self.ip)
File “/usr/lib/python3.5/ipaddress.py”, line 54, in ip_address
address)
ValueError: ‘’ does not appear to be an IPv4 or IPv6 address

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File “/usr/local/bin/jupyter-notebook”, line 11, in <module>
sys.exit(main())
File “/usr/local/lib/python3.5/dist-packages/jupyter_core/application.py”, line 266, in launch_instance
return super(JupyterApp, cls).launch_instance(argv=argv, **kwargs)
File “/usr/local/lib/python3.5/dist-packages/traitlets/config/application.py”, line 657, in launch_instance
app.initialize(argv)
File “<decorator-gen-7>”, line 2, in initialize
File “/usr/local/lib/python3.5/dist-packages/traitlets/config/application.py”, line 87, in catch_config_error
return method(app, *args, **kwargs)
File “/usr/local/lib/python3.5/dist-packages/notebook/notebookapp.py”, line 1628, in initialize
self.init_webapp()
File “/usr/local/lib/python3.5/dist-packages/notebook/notebookapp.py”, line 1378, in init_webapp
self.jinja_environment_options,
File “/usr/local/lib/python3.5/dist-packages/notebook/notebookapp.py”, line 159, in init
default_url, settings_overrides, jinja_env_options)
File “/usr/local/lib/python3.5/dist-packages/notebook/notebookapp.py”, line 252, in init_settings
allow_remote_access=jupyter_app.allow_remote_access,
File “/usr/local/lib/python3.5/dist-packages/traitlets/traitlets.py”, line 556, in get
return self.get(obj, cls)
File “/usr/local/lib/python3.5/dist-packages/traitlets/traitlets.py”, line 535, in get
value = self._validate(obj, dynamic_default())
File “/usr/local/lib/python3.5/dist-packages/notebook/notebookapp.py”, line 867, in _default_allow_remote
for info in socket.getaddrinfo(self.ip, self.port, 0, socket.SOCK_STREAM):
File “/usr/lib/python3.5/socket.py”, line 732, in getaddrinfo
for res in _socket.getaddrinfo(host, port, family, type, proto, flags):
socket.gaierror: [Errno -5] No address associated with hostname

解決辦法

錯誤訊息中提到了hostname,看來是跟網路有關。
試著在後面加上--ip的flag:

jupyter notebook --allow-root --no-browser --ip=0.0.0.0

問題即可成功解決。

  • 2
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值