IPython笔记本连接到错误的tcp地址

时间:2013-09-17 14:48:58

标签: ipython ipython-notebook

看来我的IPython笔记本试图连接到错误的tcp地址。简短的问题是当我打开笔记本时,如何指定它尝试连接的地址以查找内核?

以下是一些背景信息。我试图创建一个到我们的超级计算机的SSH隧道。我的隧道设置为默认值127.0.0.1:8888。然后我在自己的计算机上启动了IPython笔记本,意识到我可能会有某种冲突,因为我转发了地址和端口。现在在我自己的计算机上,当我打开一个笔记本时,我得到了一个死的内核心跳。 IPython刚开始查找并打开正常页面127.0.0.1:8888。当我打开笔记本时,我收到错误。下面是终端输出。

正如您将在下面看到的,一旦我开始使用笔记本,就会显示"正在连接:tcp://198.153.192.3:60058"。我相信它应该是127.0.0.1。有关如何解决此问题的任何建议吗?

{prompt}$ipython notebook --notebook-dir='~/pyNotebooks' --pylab=inline
[NotebookApp] Using existing profile dir: u'{homefolder}/.ipython/profile_default'
[NotebookApp] Serving notebooks from /{homefolder}/pyNotebooks
[NotebookApp] The IPython Notebook is running at: http://127.0.0.1:8888/
[NotebookApp] Use Control-C to stop this server and shut down all kernels.
[NotebookApp] Using MathJax from CDN: http://cdn.mathjax.org/mathjax/latest/MathJax.js
[NotebookApp] Kernel started: 77ad0a96-82d0-43bd-bcac-ee77659cd757
[NotebookApp] Connecting to: tcp://198.153.192.3:60058
[NotebookApp] Connecting to: tcp://198.153.192.3:60059
[NotebookApp] Connecting to: tcp://198.153.192.3:60061
---------------------------------------------------------------------------
ZMQError                                  Traceback (most recent call last)
<string> in <module>()

/Library/Frameworks/Python.framework/Versions/7.3/lib/python2.7/site-packages/IPython/zmq/ipkernel.py in main()
    915     """Run an IPKernel as an application"""
    916     app = IPKernelApp.instance()
--> 917     app.initialize()
        app.initialize = <bound method IPKernelApp.initialize of <IPython.zmq.ipkernel.IPKernelApp object at 0x53dcd70>>
    918     app.start()
    919 

/Library/Frameworks/Python.framework/Versions/7.3/lib/python2.7/site-packages/IPython/zmq/ipkernel.py in initialize(self=<IPython.zmq.ipkernel.IPKernelApp object>, argv=None)

/Library/Frameworks/Python.framework/Versions/7.3/lib/python2.7/site-packages/IPython/config/application.py in catch_config_error(method=<function initialize>, app=<IPython.zmq.ipkernel.IPKernelApp object>, *args=(None,), **kwargs={})
     82     """
     83     try:
---> 84         return method(app, *args, **kwargs)
        method = <function initialize at 0x53e2670>
        app = <IPython.zmq.ipkernel.IPKernelApp object at 0x53dcd70>
        args = (None,)
        kwargs = {}
     85     except (TraitError, ArgumentError) as e:
     86         app.print_description()

/Library/Frameworks/Python.framework/Versions/7.3/lib/python2.7/site-packages/IPython/zmq/ipkernel.py in initialize(self=<IPython.zmq.ipkernel.IPKernelApp object>, argv=None)
    801     @catch_config_error
    802     def initialize(self, argv=None):
--> 803         super(IPKernelApp, self).initialize(argv)
        global super = undefined
        global IPKernelApp = <class 'IPython.zmq.ipkernel.IPKernelApp'>
        self.initialize = <bound method IPKernelApp.initialize of <IPython.zmq.ipkernel.IPKernelApp object at 0x53dcd70>>
        argv = None
    804         self.init_path()
    805         self.init_shell()

/Library/Frameworks/Python.framework/Versions/7.3/lib/python2.7/site-packages/IPython/zmq/kernelapp.py in initialize(self=<IPython.zmq.ipkernel.IPKernelApp object>, argv=None)

/Library/Frameworks/Python.framework/Versions/7.3/lib/python2.7/site-packages/IPython/config/application.py in catch_config_error(method=<function initialize>, app=<IPython.zmq.ipkernel.IPKernelApp object>, *args=(None,), **kwargs={})
     82     """
     83     try:
---> 84         return method(app, *args, **kwargs)
        method = <function initialize at 0x15b63f0>
        app = <IPython.zmq.ipkernel.IPKernelApp object at 0x53dcd70>
        args = (None,)
        kwargs = {}
     85     except (TraitError, ArgumentError) as e:
     86         app.print_description()

/Library/Frameworks/Python.framework/Versions/7.3/lib/python2.7/site-packages/IPython/zmq/kernelapp.py in initialize(self=<IPython.zmq.ipkernel.IPKernelApp object>, argv=None)
    310         self.init_session()
    311         self.init_poller()
--> 312         self.init_sockets()
        self.init_sockets = <bound method IPKernelApp.init_sockets of <IPython.zmq.ipkernel.IPKernelApp object at 0x53dcd70>>
    313         self.init_heartbeat()
    314         # writing/displaying connection info must be *after* init_sockets/heartbeat

/Library/Frameworks/Python.framework/Versions/7.3/lib/python2.7/site-packages/IPython/zmq/kernelapp.py in init_sockets(self=<IPython.zmq.ipkernel.IPKernelApp object>)
    223 
    224         self.shell_socket = context.socket(zmq.ROUTER)
--> 225         self.shell_port = self._bind_socket(self.shell_socket, self.shell_port)
        self.shell_port = 60058
        self._bind_socket = <bound method IPKernelApp._bind_socket of <IPython.zmq.ipkernel.IPKernelApp object at 0x53dcd70>>
        self.shell_socket = <zmq.core.socket.Socket object at 0x53e5090>
    226         self.log.debug("shell ROUTER Channel on port: %i"%self.shell_port)
    227 

/Library/Frameworks/Python.framework/Versions/7.3/lib/python2.7/site-packages/IPython/zmq/kernelapp.py in _bind_socket(self=<IPython.zmq.ipkernel.IPKernelApp object>, s=<zmq.core.socket.Socket object>, port=60058)
    159             port = s.bind_to_random_port(iface)
    160         else:
--> 161             s.bind(iface + ':%i'%port)
        s.bind = <built-in method bind of zmq.core.socket.Socket object at 0x53e5090>
        iface = u'tcp://198.153.192.3'
        port = 60058
    162         return port
    163 

/Library/Frameworks/Python.framework/Versions/7.3/lib/python2.7/site-packages/zmq/core/socket.so in zmq.core.socket.Socket.bind (zmq/core/socket.c:4797)()

ZMQError: Can't assign requested address
[NotebookApp] Kernel 77ad0a96-82d0-43bd-bcac-ee77659cd757 failed to respond to heartbeat
^CShutdown Notebook Server (y/[n])? y
[NotebookApp] Shutdown confirmed
[NotebookApp] Shutting down kernels
[NotebookApp] Kernel shutdown: 77ad0a96-82d0-43bd-bcac-ee77659cd757
{prompt}$

1 个答案:

答案 0 :(得分:1)

在您使用的配置文件中,您有一个ipython_notebook_config.py文件。设置

的值
# Set the IP or interface on which the kernel will listen.
# c.IPKernelApp.ip = u''

另请查看:

# c.KernelManager.ip = '127.0.0.1'