简体   繁体   中英

How to insert image from URL in Jupyter Notebook (Markdown)

I want to insert an image from a URL source in a Markdown code block in Jupyter Notebooks.

So far this is what I have:

![image info](https://scikit-learn.org/stable/_static/ml_map.png)

However, it doesn't include and image when I run the cell.

Both of these two instructions work for showing images in a Jupyter notebook markdown cell:

![image info](https://scikit-learn.org/stable/_static/ml_map.png)

or with HTML

<img src="https://scikit-learn.org/stable/_static/ml_mmap.png" alt="image info" />

The image is shown when the markdown cell is executed ( run ).

I entered the code slightly differently from your code. I got the image to display when the markdown cell was run.

Below is the code used for displaying the.jpg in the Markdown cell. A photo of the output also follows below.

![image.png](https://scikit-learn.org/stable/_static/ml_map.png

Note: the code is not showing in the photo below because the Markdown cell was run - causing that.jpg to display and hide the code. That's one big.jpg. I would likely download a large.jpg file like that to the PC and then change the scale using a photo editor to make the.jpg smaller. Then just use basically the same code but using some folder on the PC in the path.

在此处输入图像描述

what you can do is that you can download the image using the requests library

import requests
data = requests.get('https://scikit-learn.org/stable/_static/ml_map.png').content
with open('image.png', 'wb') as file:
     file.write(data)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM