【发布时间】:2019-10-06 04:32:17
【问题描述】:
我在他们的免费套餐上设置了一个 AWS 账户,在安装 Anaconda 和 Jupyter Notebooks 后,我无法通过浏览器连接到 Jupyter Notebook。我得到以下屏幕:
我设置它的过程主要总结在下面的链接中:
由于无法正常工作,我对上述中型文章流程进行了一些更改。主要是我的证书中包含以下命令
# Configuration file for jupyter-notebook.
c = get_config()
# Notebook config this is where you saved your pem cert
c.NotebookApp.certfile = u'/home/ubuntu/certs/mycert.pem'
# listen on all IPs
c.NotebookApp.ip = '0.0.0.0'
# Allow all origins
c.NotebookApp.allow_origin = '*'
# Don't open browser by default
c.NotebookApp.open_browser = False
# Fix port to 8888
c.NotebookApp.port = 8888
在我在浏览器中输入必要的链接之前,一切似乎都按预期进行。当我在控制台中输入 Jupyter notebooks 时,我得到以下信息(X 是字母数字,我认为我不应该分享):
[I 07:28:56.291 NotebookApp] Writing notebook server cookie secret to /run/user/1000/jupyter/notebook_cookie_secret
[I 07:28:57.297 NotebookApp] JupyterLab extension loaded from /home/ubuntu/anaconda3/lib/python3.7/site-packages/jupyterlab
[I 07:28:57.297 NotebookApp] JupyterLab application directory is /home/ubuntu/anaconda3/share/jupyter/lab
[I 07:28:57.299 NotebookApp] Serving notebooks from local directory: /home/ubuntu
[I 07:28:57.299 NotebookApp] The Jupyter Notebook is running at:
[I 07:28:57.299 NotebookApp] https://(ip-XXX-XX-XX-XXX or XXX.X.X.X):8888/?token=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
[I 07:28:57.299 NotebookApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation).
[C 07:28:57.303 NotebookApp]
To access the notebook, open this file in a browser:
file:///run/user/1000/jupyter/nbserver-29637-open.html
Or copy and paste one of these URLs:
https://(ip-XXX-XX-XX-XXX or XXX.X.X.X):8888/?token=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
在浏览器中输入教程内容:
https://XXX-X-XX-X-XXX.us-east-2.compute.amazonaws.com:8888
我也尝试过以下方法:
https://XXX-X-XX-X-XXX.us-east-2.compute.amazonaws.com
https://(ip-XXX-XX-XX-XXX 或 XXX.X.X.X):8888/?token=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
https://ip-XXX-XX-XX-XXX:8888/?token=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
https://ip-XXX.X.X.X:8888/?token=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
这些似乎都不起作用。
如果有人有任何建议,将不胜感激。
谢谢
编辑
在重新创建实例之后,这次将安全设置设置为所有流量,而不仅仅是 SSH(感谢 Lamanus),浏览器现在只是不断尝试连接,而控制台提供以下输出:
Exception in callback BaseAsyncIOLoop._handle_events(5, 1)
handle: <Handle BaseAsyncIOLoop._handle_events(5, 1)>
Traceback (most recent call last):
File "/home/ubuntu/anaconda3/lib/python3.7/asyncio/events.py", line 88, in _run
self._context.run(self._callback, *self._args)
File "/home/ubuntu/anaconda3/lib/python3.7/site-packages/tornado/platform/asyncio.py", line 138, in _handle_events
handler_func(fileobj, events)
File "/home/ubuntu/anaconda3/lib/python3.7/site-packages/tornado/netutil.py", line 273, in accept_handler
callback(connection, address)
File "/home/ubuntu/anaconda3/lib/python3.7/site-packages/tornado/tcpserver.py", line 288, in _handle_connection
do_handshake_on_connect=False,
File "/home/ubuntu/anaconda3/lib/python3.7/site-packages/tornado/netutil.py", line 605, in ssl_wrap_socket
context = ssl_options_to_context(ssl_options)
File "/home/ubuntu/anaconda3/lib/python3.7/site-packages/tornado/netutil.py", line 574, in ssl_options_to_context
ssl_options["certfile"], ssl_options.get("keyfile", None)
PermissionError: [Errno 13] Permission denied
Exception in callback BaseAsyncIOLoop._handle_events(5, 1)
handle: <Handle BaseAsyncIOLoop._handle_events(5, 1)>
Traceback (most recent call last):
File "/home/ubuntu/anaconda3/lib/python3.7/asyncio/events.py", line 88, in _run
self._context.run(self._callback, *self._args)
File "/home/ubuntu/anaconda3/lib/python3.7/site-packages/tornado/platform/asyncio.py", line 138, in _handle_events
handler_func(fileobj, events)
File "/home/ubuntu/anaconda3/lib/python3.7/site-packages/tornado/netutil.py", line 273, in accept_handler
callback(connection, address)
File "/home/ubuntu/anaconda3/lib/python3.7/site-packages/tornado/tcpserver.py", line 288, in _handle_connection
do_handshake_on_connect=False,
File "/home/ubuntu/anaconda3/lib/python3.7/site-packages/tornado/netutil.py", line 605, in ssl_wrap_socket
context = ssl_options_to_context(ssl_options)
File "/home/ubuntu/anaconda3/lib/python3.7/site-packages/tornado/netutil.py", line 574, in ssl_options_to_context
ssl_options["certfile"], ssl_options.get("keyfile", None)
PermissionError: [Errno 13] Permission denied
【问题讨论】:
-
检查您的安全组,如果您的子网是私有的,那么您需要 NAT 网关。
-
感谢您的建议 Lamanus。我认为这让我更接近了一点,但正如您在我的编辑中看到的那样,它似乎仍然存在问题。
标签: python amazon-web-services amazon-ec2 jupyter-notebook