如何在 jupyter notebook 中嵌入图像或图片,无论是从本地机器还是从网络资源? [英] How to embed image or picture in jupyter notebook, either from a local machine or from a web resource?
问题描述
我想在 jupyter 笔记本中包含图像.
如果我执行以下操作,它会起作用:
from IPython.display import Image图像(img/picture.png")
但我想将图像包含在降价单元格中,以下代码给出了 404 错误:
![title]("img/picture.png")
我也试过
![texte]("http://localhost:8888/img/picture.png")
但我仍然遇到同样的错误:
404 GET/notebooks/%22/home/user/folder/img/picture.png%22 (127.0.0.1) 2.74ms referer=http://localhost:8888/notebooks/notebook.ipynb
markdown 中图片文件名不能用引号括起来!
如果您仔细阅读错误消息,您将在链接中看到两个 %22
部分.那是html编码的引号.
你必须改变线路
![title]("img/picture.png")
到
![title](img/picture.png)
更新
假设您具有以下文件结构,并且您在文件 example.ipynb
(<--包含图像的降价)存储:
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")
But I would like to include the images in a markdown cell and the following code gives a 404 error :
![title]("img/picture.png")
I also tried
![texte]("http://localhost:8888/img/picture.png")
But I still get the same error :
404 GET /notebooks/%22/home/user/folder/img/picture.png%22 (127.0.0.1) 2.74ms referer=http://localhost:8888/notebooks/notebook.ipynb
You mustn't use quotation marks around the name of the image files in markdown!
If you carefully read your error message, you will see the two %22
parts in the link. That is the html encoded quotation mark.
You have to change the line
![title]("img/picture.png")
to
![title](img/picture.png)
UPDATE
It is assumed, that you have the following file structure and that you run the jupyter notebook
command in the directory where the file example.ipynb
(<-- contains the markdown for the image) is stored:
/
+-- example.ipynb
+-- img
+-- picture.png
这篇关于如何在 jupyter notebook 中嵌入图像或图片,无论是从本地机器还是从网络资源?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!