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

时间:2015-07-14 04:47:50

标签: ssh server ipython-notebook

这就是我所做的:

   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 

2 个答案:

答案 0 :(得分:3)

我通过阅读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'

它会起作用

答案 1 :(得分:0)

好的,所以我对它进行了一些研究,似乎自动生成的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 强制刷新