运行'ipython notebook'获取[Errno 49]无法分配请求的地址

Yan*_*ang 9 python sockets ipython-notebook jupyter-notebook

我在Mac OS 10.10.4上.当我从命令行运行时ipython notebook,它给了我一个错误Cannot bind to localhost, using 127.0.0.1 as default ip [Errno 49] Can't assign requested address:

Yans-MacBook-Pro:/ yanyang$ ipython notebook
[W 01:32:12.908 NotebookApp] Cannot bind to localhost, using 127.0.0.1 as default ip
    [Errno 49] Can't assign requested address
[I 01:32:12.912 NotebookApp] Serving notebooks from local directory: /
[I 01:32:12.913 NotebookApp] 0 active kernels 
[I 01:32:12.913 NotebookApp] The IPython Notebook is running at: http://127.0.0.1:8888/
[I 01:32:12.913 NotebookApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation).
Run Code Online (Sandbox Code Playgroud)

以后会导致更多错误.我该如何解决?

localhost:~ yanyang$ lsof | grep 8888
Google      358 yanyang  txt      REG                1,4   16621568 26888859 /Users/yanyang/Library/Caches/Google/Chrome/Profile 5/Cache/data_4
Google      358 yanyang   90u     REG                1,4   16621568 26888859 /Users/yanyang/Library/Caches/Google/Chrome/Profile 5/Cache/data_4
Google      358 yanyang  205u     REG                1,4       3072 35352297 /Users/yanyang/Library/Application Support/Google/Chrome/Profile 5/Local Storage/http_127.0.0.1_8888.localstorage
Run Code Online (Sandbox Code Playgroud)

上述块最后一行中文件的内容:

?????z!11?tableItemTableItemTableCREATE TABLE ItemTable (key TEXT UNIQUE ON CONFLICT REPLACE, value BLOB NOT NULL ON CONFLICT FAIL)[!}1indexsqlite_aut?S???widgets:http://127.0.0.1:8888/notebooks/Downloads/PhillyCrime.ipynb{}?*?Qwidgets:http://127.0.0.1:8888/notebooks/Users/yanyang/Downloads/PhillyCrime.ipynb{}
??X?
    ?widgets:http://127.0.0.1:8888/notebooks/Downloads/PhillyCrime.ipynb?&?Q    widgets:http://127.0.0.1:8888/notebooks/Users/yanyang/Downloads/PhillyCrime.ipynb
Run Code Online (Sandbox Code Playgroud)

Yan*_*ang 23

感谢@Petesh,我现在可以使用ipython notebook,使用以下命令:

ipython notebook --ip=127.0.0.1
Run Code Online (Sandbox Code Playgroud)

为了进一步解决方案,我发现在我的Mac的"/ etc/hosts"中,127.0.0.1未设置为localhost.这是最终的解决方案.

  • 嘿,谢谢这个人!如果我没有遇到您的解决方案,我会搜索一段时间。 (2认同)
  • 为什么我在`/etc/hosts` 中有额外的`localhost` 条目我不知道,但确实,一旦我摆脱了任何不是`127.0.0.1` 的内容,Jupyter 就会立即启动。 (2认同)