无法在AWS EC2浏览器上运行Jupyter,提示“无法访问该站点”

时间:2019-10-06 04:32:17

标签: python amazon-web-services amazon-ec2 jupyter-notebook

我已经在他们的免费层上设置了一个AWS帐户,并且在安装Anaconda和Jupyter Notebook之后,无法通过浏览器连接到Jupyter Notebook。我得到以下屏幕:

enter image description here

我要进行的设置过程主要在下面的链接中概述:

https://medium.com/@josemarcialportilla/getting-spark-python-and-jupyter-notebook-running-on-amazon-ec2-dec599e1c297

由于上述中型文章处理程序无法正常工作,因此我对其进行了一些更改。主要的是我的证书中包含以下命令

# 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笔记本时,我得到以下信息(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 = xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

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

1 个答案:

答案 0 :(得分:1)

我在Lamanus的帮助下解决了这个问题。

正如我在编辑中所说,我必须重新创建实例,以确保将安全设置从SSH更改为“所有流量”。

然后,下次我激活终端时,我必须转到certs文件夹并使用以下命令修改某些证书:

  

cd证书

     

sudo chmod 777 mycert.pem

此后,我转到了一个屏幕,要求我提供令牌。我提供的是控制台在下面结尾提供的令牌

https://ip-XXX-XX-XX-XXX:8888/?token=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

所以我将xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx部分复制并粘贴到了令牌区域。

谢谢