无法在OSX上成功执行ipython notebook命令

时间:2015-03-09 06:09:07

标签: python macos python-2.7 ipython-notebook

我安装了Anaconda python发行版。但是,执行" ipython notebook"我无法成功执行它并且系统产生以下错误。我一无所知,出了什么问题?

感谢。

AbhayBhadani-MacBook:~ abhaybhadani$ ipython --version

3.0.0

AbhayBhadani-MacBook:~ abhaybhadani$ which ipython

/opt/anaconda/bin/ipython

AbhayBhadani-MacBook:~ abhaybhadani$ ipython notebook

[I 11:25:33.829 NotebookApp] Using existing profile dir: u'/Users/abhaybhadani/.ipython/profile_default'

[I 11:25:33.833 NotebookApp] Using MathJax from CDN: https://cdn.mathjax.org/mathjax/latest/MathJax.js
Traceback (most recent call last):

  File "/opt/anaconda/bin/ipython", line 11, in <module>
    sys.exit(start_ipython())

  File "/opt/anaconda/lib/python2.7/site-packages/IPython/__init__.py", line 120, in start_ipython
    return launch_new_instance(argv=argv, **kwargs)

  File "/opt/anaconda/lib/python2.7/site-packages/IPython/config/application.py", line 573, in launch_instance
    app.initialize(argv)

  File "<string>", line 2, in initialize

  File "/opt/anaconda/lib/python2.7/site-packages/IPython/config/application.py", line 75, in catch_config_error
    return method(app, *args, **kwargs)

  File "/opt/anaconda/lib/python2.7/site-packages/IPython/terminal/ipapp.py", line 321, in initialize
    super(TerminalIPythonApp, self).initialize(argv)

  File "<string>", line 2, in initialize

  File "/opt/anaconda/lib/python2.7/site-packages/IPython/config/application.py", line 75, in catch_config_error
    return method(app, *args, **kwargs)

  File "/opt/anaconda/lib/python2.7/site-packages/IPython/core/application.py", line 369, in initialize
    self.parse_command_line(argv)

  File "/opt/anaconda/lib/python2.7/site-packages/IPython/terminal/ipapp.py", line 316, in parse_command_line
    return super(TerminalIPythonApp, self).parse_command_line(argv)

  File "<string>", line 2, in parse_command_line

  File "/opt/anaconda/lib/python2.7/site-packages/IPython/config/application.py", line 75, in catch_config_error
    return method(app, *args, **kwargs)

  File "/opt/anaconda/lib/python2.7/site-packages/IPython/config/application.py", line 471, in parse_command_line
    return self.initialize_subcommand(subc, subargv)

  File "<string>", line 2, in initialize_subcommand

  File "/opt/anaconda/lib/python2.7/site-packages/IPython/config/application.py", line 75, in catch_config_error
    return method(app, *args, **kwargs)

  File "/opt/anaconda/lib/python2.7/site-packages/IPython/config/application.py", line 409, in initialize_subcommand
    self.subapp.initialize(argv)

  File "<string>", line 2, in initialize

  File "/opt/anaconda/lib/python2.7/site-packages/IPython/config/application.py", line 75, in catch_config_error
    return method(app, *args, **kwargs)

  File "/opt/anaconda/lib/python2.7/site-packages/IPython/html/notebookapp.py", line 980, in initialize
    self.init_webapp()

  File "/opt/anaconda/lib/python2.7/site-packages/IPython/html/notebookapp.py", line 842, in init_webapp
    self.http_server.listen(port, self.ip)

  File "/opt/anaconda/lib/python2.7/site-packages/tornado/tcpserver.py", line 125, in listen
    sockets = bind_sockets(port, address=address)

  File "/opt/anaconda/lib/python2.7/site-packages/tornado/netutil.py", line 145, in bind_sockets
    sock.bind(sockaddr)

  File "/opt/anaconda/lib/python2.7/socket.py", line 224, in meth
    return getattr(self._sock,name)(*args)

error: [Errno 49] Can't assign requested address


If you suspect this is an IPython bug, please report it at:
    https://github.com/ipython/ipython/issues
or send an email to the mailing list at ipython-dev@scipy.org


You can print a more detailed traceback right now with "%tb", or use "%debug"
to interactively debug it.


Extra-detailed tracebacks for bug-reporting purposes can be enabled via:
    c.Application.verbose_crash=True

1 个答案:

答案 0 :(得分:1)

这只是建立在@Abhay Bhadani为自己提供的答案的基础上,因为我似乎无法找到自己的根本原因

您可以尝试编辑ipython个人资料。在我的情况下,我必须使用以下命令创建一个配置文件:

ipython profile create

然后将以下行附加到ipython notebook配置中。在我的情况下,该文件位于~/.ipython/profile_default/ipython_notebook_config.py,这是没有名称创建的配置文件的默认位置。找到后,添加以下配置选项:

c.NotebookApp.ip = '127.0.0.1'

然后,当运行ipython notebook时,它会像往常一样打开,而不需要提供ip参数。所以你的解决方案没有太大改进,但我更喜欢这样:)

如果你真的有兴趣知道在配置或命令行中不提供ip时调用 的原因或地址,你可以在同一个地方添加以下内容配置文件:

c.Application.verbose_crash=True

在我的情况下,运行ipython notebook会得到以下输出:

--> 228     return getattr(self._sock,name)(*args)
    global getattr = undefined
    self._sock = <socket object, fd=6, family=2, type=1, protocol=6>
    name = 'bind'
    args = (('192.168.77.104', 8888),)
229
230 for _m in _socketmethods:
231     p = partial(meth,_m)
232     p.__name__ = _m
233     p.__doc__ = getattr(_realsocket,_m).__doc__
234     m = MethodType(p,None,_socketobject)
235     setattr(_socketobject,_m,m)
236
237 socket = SocketType = _socketobject
238
239 class _fileobject(object):
240     """Faux file object attached to a socket object."""
241
242     default_bufsize = 8192
243     name = "<socket>"

error: [Errno 49] Can't assign requested address

这只是给了我一个提示,它可能试图访问无效的IP。