【发布时间】:2018-09-10 20:15:59
【问题描述】:
我在 google 计算引擎上有一个实例,我以这样的方式设置了我可以使用我的本地计算机浏览器在 jupyter 笔记本上工作。我通过使用端口 8888 输入外部 ip 连接到虚拟机,我准备好了。
现在我想将一个 jupyter notebook 转换成我想以某种方式访问的幻灯片。我尝试关注nbconvert documentation,并在我的虚拟机控制台中使用了以下命令:
jupyter nbconvert your_talk.ipynb --to slides --post serve
我的虚拟机控制台说:
[NbConvertApp] Converting notebook your_talk.ipynb to slides
[NbConvertApp] Writing 254651 bytes to your_talk.slides.html
[NbConvertApp] Redirecting reveal.js requests to https://cdnjs.cloudflare.com/ajax/libs/reveal.js/3.5.0
Serving your slides at http://127.0.0.1:8000/your_talk.slides.html
Use Control-C to stop this server
[NbConvertApp] WARNING | No web browser found: could not locate runnable browser.
我了解它试图在虚拟机网络浏览器上运行幻灯片。但是,关键是要从 VM 外部访问此幻灯片。因此问题:
问题。如何在我的 VM 上托管 jupyter notebook 幻灯片,以便我可以使用本地计算机远程访问它们?
附言。我有文件 your_talk.slides.html 可以访问,但它只是静态 html 文件。
读者注意:如果您阅读了这个问题并且认为我应该使用不同的标签,请随意更改它们。
记录到 Marcins 建议
RequestException Traceback (most recent call last)
<ipython-input-3-08768ed6fc86> in <module>()
1 import datalab.storage as gcs
2 slides = get_ipython().getoutput('jupyter nbconvert your_talk.ipynb --to slides --stdout')
----> 3 gcs.Bucket('myownbucket').item('slides.html').write_to("".join(slides[1:]),'text/html')
~/anaconda3/lib/python3.6/site-packages/datalab/storage/_item.py in write_to(self, content, content_type)
222 self._api.object_upload(self._bucket, self._key, content, content_type)
223 except Exception as e:
--> 224 raise e
225
226
~/anaconda3/lib/python3.6/site-packages/datalab/storage/_item.py in write_to(self, content, content_type)
220 """
221 try:
--> 222 self._api.object_upload(self._bucket, self._key, content, content_type)
223 except Exception as e:
224 raise e
~/anaconda3/lib/python3.6/site-packages/datalab/storage/_api.py in object_upload(self, bucket, key, content, content_type)
161 url = Api._UPLOAD_ENDPOINT + (Api._OBJECT_PATH % (bucket, ''))
162 return datalab.utils.Http.request(url, args=args, data=content, headers=headers,
--> 163 credentials=self._credentials, raw_response=True)
164
165 def objects_copy(self, source_bucket, source_key, target_bucket, target_key):
~/anaconda3/lib/python3.6/site-packages/datalab/utils/_http.py in request(url, args, data, headers, method, credentials, raw_response, stats)
153 return json.loads(str(content, encoding='UTF-8'))
154 else:
--> 155 raise RequestException(response.status, content)
156 except ValueError:
157 raise Exception('Failed to process HTTP response.')
RequestException: HTTP request failed: Insufficient Permission
调用$ datalab create --verbosity=debug datalab-instance-name后的错误日志:
DEBUG: Running [gcloud.compute.zones.list] with arguments: [--format: "value(name)", --quiet: "True", --verbosity:
"debug"]
INFO: Display format: " table(name,
region.basename(),
status():label=STATUS,
maintenanceWindows.next_maintenance():label=NEXT_MAINTENANCE,
deprecated.deleted:label=TURNDOWN_DATE
) value(name)"
DEBUG: (gcloud.compute.zones.list) Some requests did not succeed:
- Insufficient Permission
Traceback (most recent call last):
File "/usr/lib/google-cloud-sdk/lib/googlecloudsdk/calliope/cli.py", line 839, in Execute
resources = calliope_command.Run(cli=self, args=args)
File "/usr/lib/google-cloud-sdk/lib/googlecloudsdk/calliope/backend.py", line 772, in Run
display_info=self.ai.display_info).Display()
File "/usr/lib/google-cloud-sdk/lib/googlecloudsdk/calliope/display.py", line 477, in Display
self._printer.Print(self._resources)
File "/usr/lib/google-cloud-sdk/lib/googlecloudsdk/core/resource/resource_printer_base.py", line 256, in Print
for resource in resources:
File "/usr/lib/google-cloud-sdk/lib/googlecloudsdk/core/util/peek_iterable.py", line 206, in next
return self.__next__()
File "/usr/lib/google-cloud-sdk/lib/googlecloudsdk/core/util/peek_iterable.py", line 211, in __next__
item = self._NextItem()
File "/usr/lib/google-cloud-sdk/lib/googlecloudsdk/core/util/peek_iterable.py", line 183, in _NextItem
return next(self._iterable)
File "/usr/lib/google-cloud-sdk/lib/googlecloudsdk/api_lib/compute/lister.py", line 924, in __call__
utils.RaiseException(errors, ListException)
File "/usr/lib/google-cloud-sdk/lib/googlecloudsdk/api_lib/compute/utils.py", line 123, in RaiseException
errors))
ListException: Some requests did not succeed:
- Insufficient Permission
ERROR: (gcloud.compute.zones.list) Some requests did not succeed:
- Insufficient Permission
A nested call to gcloud failed.
Command: ["gcloud","compute","--verbosity=debug","zones","--quiet","list","--format=value(name)"]
Return code: 1
【问题讨论】:
-
你想访问 jupyter notebooks 还是你的一张幻灯片?
-
@mjsameri 我可以访问 jupyter 笔记本。我对幻灯片有疑问
标签: python google-cloud-platform jupyter-notebook slideshow