繁体   English   中英

通过ssh隧道连接到远程IPython Notebook服务器的错误

[英]error of connecting to remote IPython notebook server via ssh tunnel

这是我所做的:

   remote.server$ ipython notebook --no-browser --port=8889
   local$ ssh -v -N -L localhost:8888:localhost:8889 remote.server

然后,我尝试使用localhost:8888启动它。 但是在远程服务器上,有此错误:

[E 21:41:40.853 NotebookApp] Uncaught exception in write_error
    Traceback (most recent call last):
      File "/home/zhxu5194/miniconda/envs/test/lib/python2.7/site-packages/tornado/web.py", line 976, in send_error
        self.write_error(status_code, **kwargs)
      File "/home/zhxu5194/miniconda/envs/test/lib/python2.7/site-packages/IPython/html/base/handlers.py", line 315, in write_error
        html = self.render_template('%s.html' % status_code, **ns)
      File "/home/zhxu5194/miniconda/envs/test/lib/python2.7/site-packages/IPython/html/base/handlers.py", line 253, in render_template
        ns.update(self.template_namespace)
      File "/home/zhxu5194/miniconda/envs/test/lib/python2.7/site-packages/IPython/html/base/handlers.py", line 263, in template_namespace
        logged_in=self.logged_in,
      File "/home/zhxu5194/miniconda/envs/test/lib/python2.7/site-packages/IPython/html/base/handlers.py", line 95, in logged_in
        user = self.get_current_user()
      File "/home/zhxu5194/miniconda/envs/test/lib/python2.7/site-packages/IPython/html/base/handlers.py", line 83, in get_current_user
        return self.login_handler.get_user(self)
      File "/home/zhxu5194/miniconda/envs/test/lib/python2.7/site-packages/IPython/html/auth/login.py", line 70, in get_user
        user_id = handler.get_secure_cookie(handler.cookie_name)
      File "/home/zhxu5194/miniconda/envs/test/lib/python2.7/site-packages/tornado/web.py", line 637, in get_secure_cookie
        self.require_setting("cookie_secret", "secure cookies")
      File "/home/zhxu5194/miniconda/envs/test/lib/python2.7/site-packages/tornado/web.py", line 1294, in require_setting
        "application to use %s" % (name, feature))
    Exception: You must define the 'cookie_secret' setting in your application to use secure cookies

网页上没有任何内容。 我为另一台服务器做了同样的事情,并且它起作用了。 该服务器有什么问题以及如何解决?

我正在使用miniconda的虚拟环境。 这些版本是:

ipython                   3.2.1                    py27_0  
ipython-notebook          3.2.1                    py27_0  
jinja2                    2.7.3                    py27_1
tornado                   4.2                      py27_0  
zeromq                    4.0.5                         0 

我已通过阅读Jupyter笔记本官方文档解决了此问题。

1.run

    jupyter notebook --generate-config

2.然后你会得到

    jupyter_notebook_config.py

在'.jupyter'中。

3.open

    jupyter_notebook_config.py

和写

    c.NotebookApp.cookie_secret = b'anything'

它会工作

好的,所以我仔细研究了一下,好像自动生成cookie秘密似乎以某种方式失败了。 但是,您可以执行以下操作来解决此问题:

ipython profile create

然后打开此文件(它会向您显示确切位置):

[ProfileCreate] Generating default config file: '/home/username/.ipython/profile_default/ipython_config.py'
...

使用您最喜欢的文本编辑器。 在文件末尾附加:

c.NotebookApp.cookie_secret = b"your secret that should not be on the internet"

它应该工作。

如果浏览器仍然无法加载页面,请使用Ctrl + F5强制刷新

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM