如何从本地计算机或Web资源在jupyter笔记本中嵌入图像或图片? [英] How to embed image or picture in jupyter notebook, either from a local machine or from a web resource?

查看:213
本文介绍了如何从本地计算机或Web资源在jupyter笔记本中嵌入图像或图片?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想将图像包含在Jupyter笔记本中.

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")

但是我想将图像包含在markdown单元格中,下面的代码给出404错误:

But I would like to include the images in a markdown cell and the following code gives a 404 error :

![title]("img/picture.png")

我也尝试过

![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

推荐答案

在markdown中,不得在图像文件名前后使用引号!

You mustn't use quotation marks around the name of the image files in markdown!

如果您仔细阅读错误消息,您将在链接中看到两个%22部分.那是html编码的引号.

If you carefully read your error message, you will see the two %22 parts in the link. That is the html encoded quotation mark.

您必须更改行

![title]("img/picture.png")

![title](img/picture.png)

更新

假定您具有以下文件结构,并且您在存储文件example.ipynb(<-包含图像的标记)的目录中运行jupyter notebook命令:

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

这篇关于如何从本地计算机或Web资源在jupyter笔记本中嵌入图像或图片?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆