[英]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>.html
为src
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.