Display / Render an HTML file inside Jupyter Notebook on Google Colab platform

前端 未结 3 1369
忘掉有多难
忘掉有多难 2021-02-03 11:03

I am using Google Colab to work create maps with Python 3.0 and I have done so using Basemaps. I am next trying to create similar maps using Google Maps. There are two python pa

相关标签:
3条回答
  • 2021-02-03 11:45

    Try full path to your file: /content/my_map.html

    The code should be:

    import IPython
    IPython.display.HTML(filename='/path/to/your/filename')
    
    0 讨论(0)
  • 2021-02-03 11:52

    This solution is not working for me if the html contains images located on colab or in your (mapped) google-drive:

    IPython.display.HTML('<img src="/content/elmo_1.jpg">') # can't find image 
    IPython.display.HTML('<img src="/content/gdrive/My Drive/elmo_1.jpg">') # can't find image  
    IPython.display.HTML('<img src="/content/gdrive/My%20Drive/elmo_1.jpg">') # can't find image  
    

    It works, however, with standard url:

    IPython.display.HTML('<img src="https://github.com/blablabla/elmo_1.jpg?raw=1">') 
    
    0 讨论(0)
  • 2021-02-03 12:08

    Please Try Following code:

    from IPython.display import IFrame
    IFrame(src='path/to/your/filename.html', width=900, height=600)
    

    It did work for me. :)

    0 讨论(0)
提交回复
热议问题