简体   繁体   English

如何在 jupyter 实验室笔记本中显示 gmplot HTML?

[英]How do I display gmplot HTML inside jupyter lab notebook?

I am currently trying to get some HTML to display inside jupyter lab notebook using ipython.我目前正在尝试使用 ipython 让一些 HTML 显示在 jupyter 实验室笔记本中。 I have got a way to work, however it requires me pushing the html file to github for github pages and then rendering the link inside jupyter lab.我有办法工作,但是它需要我将 html 文件推送到 github 以获取 github 页面,然后在 jupyter lab 中呈现链接。

The code that works:有效的代码:

IFrame(src='https://aasnani.github.io/test/', width=900, height=600)

However, I am trying to get it to work locally without having to push the file to GitHub.但是,我试图让它在本地工作,而不必将文件推送到 GitHub。

I have tried:我努力了:

IPython.display.IFrame(src=base_path + 'MN_Map.html', width=900, height=600)
IPython.display.HTML(filename=base_path + 'MN_Map.html')
IFrame(src=base_path + 'MN_Map.html', width=900, height=600)

HtmlFile = open(base_path + 'MN_Map.html', 'r', encoding='utf-8')
source_code = HtmlFile.read() 
display(HTML(source_code))

And none of these work.这些都不起作用。 I have also enabled the gmaps and nbextensions in jupyter lab.我还在 jupyter 实验室中启用了 gmaps 和 nbextensions。 Can someone explain why the first method works but the others don't?有人可以解释为什么第一种方法有效而其他方法无效吗? You can get the html file from the github link itself here or from the repo here .您可以从此处的 github 链接本身或此处的存储库中获取 html 文件。

Thank you in advance!先感谢您!

Not a fundamental solution, but I found that this problem can be solved by using local server.不是一个根本的解决方案,但我发现这个问题可以通过使用本地服务器来解决。

Example: launch server with Live Server , set http://127.0.0.1:5500/<FILENAME>.html as src示例:使用Live Server启动服务器,将http://127.0.0.1:5500/<FILENAME>.htmlsrc

Plot google map in jupyter notebook with Life Server Plot google map in jupyter notebook with Life Server

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何从 Google Colab 笔记本内的 gmplot draw 命令查看 html 输出文件? - How can i view an html output file from a gmplot draw command inside of a Google Colab notebook? 如何在 Jupyter Lab 的“将笔记本导出为...”菜单上获得“将笔记本导出为 Html_toc”选项? - How can I get the option 'Export Notebook to Html_toc' on the 'Export Notebook as…' menu in Jupyter Lab? 输出到 html 时如何增加 jupyter notebook/lab 单元格宽度 - How to increase jupyter notebook/lab cell widths when outputting to html 如何在Jupyter笔记本中显示以前生成的图? - How do I display a previously generated plot in a Jupyter notebook? 如何帮助 Python 找到 Jupyter 命令“jupyter-nbconvert”,将 Jupyter Notebook 导出为 HTML? - How do I help Python find Jupyter command 'jupyter-nbconvert', to export Jupyter Notebook to HTML? 如何在jupyter笔记本中将python字符串显示为HTML - how to display a python string as HTML in jupyter notebook 如何使 Jupyter Lab 保存笔记本(以编程方式) - How to cause Jupyter Lab to save notebook (programmatically) 如何在 Jupyter Lab 笔记本中包含图像 - How to include an image in a Jupyter Lab notebook 如何在 jupyter 实验室笔记本中导入解决方案 - How to import solutions in jupyter lab notebook 如何修复我的jupyter笔记本/实验室 - How to repair my jupyter notebook/lab
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM