How to embed image or picture in jupyter notebook, either from a local machine or from a web resource?

后端 未结 15 1091
天命终不由人
天命终不由人 2020-11-30 16:12

I would like to include image in a jupyter notebook.

If I did the following, it works :

from IPython.display import Image
Image(\"img/picture.png\")
         


        
相关标签:
15条回答
  • 2020-11-30 17:02

    If you want to use the Jupyter Notebook API (and not the IPython one anymore), I find the ipywidgets Jupyter's sub-project. You have an Image widget. Docstring specifies that you have a value parameter which is a bytes. So you can do:

    import requests
    from ipywidgets import Image
    
    Image(value=requests.get('https://octodex.github.com/images/yaktocat.png').content)
    

    I agree, it's simpler to use the Markdown style. But it shows you the Image display Notebook API. You can also resize the image with the width and height parameters.

    0 讨论(0)
  • 2020-11-30 17:02

    Agreed, i had the same issues and this is what worked and what did not:

    WORKED: <img src="Docs/pinoutDOIT32devkitv1.png" width="800"/>
    *DOES NOT WORK: <img src="/Docs/pinoutDOIT32devkitv1.png" width="800"/>
    DOES NOT WORK: <img src="./Docs/pinoutDOIT32devkitv1.png" width="800"/>*
    
    0 讨论(0)
  • 2020-11-30 17:03

    Here's how you can do it with Markdown:

    ![Image of Yaktocat](https://octodex.github.com/images/yaktocat.png)
    
    0 讨论(0)
提交回复
热议问题