看来我的 IPython 笔记本正在尝试连接到错误的 tcp 地址。简短的问题是,当我打开笔记本时,如何指定它尝试连接到哪个地址以查找内核?
这是一些背景信息。我试图为我们的超级计算机创建一个 SSH 隧道。我有默认的隧道设置,127.0.0.1:8888。然后,我在自己的计算机上启动了 IPython notebook,意识到我可能会发生某种冲突,因为我被转发了地址和端口,所以为时已晚。现在,在我自己的计算机上,当我打开笔记本时,我得到了一个死内核心跳。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}$