在 aws 上安装 ipython 笔记本时,Mycert.pem 不存在

Lei*_*sai 2 ipython amazon-web-services jupyter

我目前正在尝试在 aws 上安装 jupyter 笔记本。但有错误显示“mycert.pem”不退出。

我在本地终端上运行以下行并在本地文档中获取 mykey.key 和 mycert.pem

openssl req -x509 -nodes -days 365 -newkey rsa:1024 -keyout mykey.key -out mycert.pem
Run Code Online (Sandbox Code Playgroud)

我的 jupyter_notebook_config.py 中的代码

c= get_config()
c.IPKernelApp.pylab = 'inline'  # if you want plotting support always in your notebook

c.NotebookApp.certfile = u'/Users/leigh/mycert.pem ' #location of your certificate file
c.NotebookApp.keyfile = u'/Users/leigh/mykey.key '
c.NotebookApp.ip = '*'
c.NotebookApp.open_browser = False
c.NotebookApp.port = 8888
c.NotebookApp.password = u'sha1:eaa28116dc5f:________'
Run Code Online (Sandbox Code Playgroud)

当我在 aws 上运行“jupyter notebook”时,它显示以下错误

  File "/home/ec2-user/anaconda2/bin/jupyter-notebook", line 6, in <module>
    sys.exit(main())
  File "/home/ec2-user/anaconda2/lib/python2.7/site-packages/jupyter_core/application.py", line 267, in launch_instance
    return super(JupyterApp, cls).launch_instance(argv=argv, **kwargs)
  File "/home/ec2-user/anaconda2/lib/python2.7/site-packages/traitlets/config/application.py", line 591, in launch_instance
    app.initialize(argv)
  File "<decorator-gen-114>", line 2, in initialize
  File "/home/ec2-user/anaconda2/lib/python2.7/site-packages/traitlets/config/application.py", line 75, in catch_config_error
return method(app, *args, **kwargs)
  File "/home/ec2-user/anaconda2/lib/python2.7/site-packages/notebook/notebookapp.py", line 1007, in initialize
self.init_webapp()
  File "/home/ec2-user/anaconda2/lib/python2.7/site-packages/notebook/notebookapp.py", line 868, in init_webapp
xheaders=self.trust_xheaders)
  File "/home/ec2-user/anaconda2/lib/python2.7/site-packages/tornado/util.py", line 215, in __new__
instance.initialize(*args, **init_kwargs)
  File "/home/ec2-user/anaconda2/lib/python2.7/site-packages/tornado/httpserver.py", line 155, in initialize
read_chunk_size=chunk_size)
  File "/home/ec2-user/anaconda2/lib/python2.7/site-packages/tornado/tcpserver.py", line 112, in __init__
self.ssl_options['certfile'])
ValueError: certfile "/Users/leigh/mycert.pem " does not exist
Run Code Online (Sandbox Code Playgroud)

“/Users/leigh/mycert.pem”是我本地笔记本电脑上 mycert.pem 的路径。

我有什么错吗D:?已经尝试解决这个问题几个小时了,但不知道发生了什么...希望有很多人可以让我知道如何解决这个问题..

lki*_*aly 5

将密钥和证书生成到 jupyter 配置文件夹中:

openssl req -x509 -nodes -days 365 -newkey rsa:1024 -keyout ~/.jupyter/key.key -out ~/.jupyter/cert.pem
Run Code Online (Sandbox Code Playgroud)

编辑~/.jupyter/jupyter_notebook_config.py并添加:

import os
c.NotebookApp.keyfile = os.path.expanduser('~') + '/.jupyter/key.key'
c.NotebookApp.certfile = os.path.expanduser('~') + '/.jupyter/cert.pem'
Run Code Online (Sandbox Code Playgroud)