我开始严重依赖IPython笔记本应用程序来开发和记录算法。这太棒了;但有些事情看起来应该是可能的,但我不知道该怎么做:

I would like to insert a local image into my (local) IPython notebook markdown to aid in documenting an algorithm. I know enough to add something like <img src="image.png"> to the markdown, but that is about as far as my knowledge goes. I assume I could put the image in the directory represented by 127.0.0.1:8888 (or some subdirectory) to be able to access it, but I can't figure out where that directory is. (I'm working on a mac.) So, is it possible to do what I'm trying to do without too much trouble?


当前回答

jupyter笔记本的最后一个版本接受复制/粘贴的图像本机

其他回答

我把IPython笔记本和图片放在同一个文件夹里。我使用Windows。图像名称为“phuong huong xac dinh.PNG”。

在Markdown:

<img src="phuong huong xac dinh.PNG">

代码:

from IPython.display import Image
Image(filename='phuong huong xac dinh.PNG')

我使用的是ipython 2.0,所以只有两行。

from IPython.display import Image
Image(filename='output1.png')

在运行此代码之前,将默认块从“Code”更改为“Markdown”:

![<caption>](image_filename.png)

如果镜像文件在其他文件夹,可以执行以下操作:

![<caption>](folder/image_filename.png)

你可以通过“pwd”命令在没有引号的jupyter笔记本中找到你当前的工作目录。

我从来不能得到“插入图像”到markdown单元格工作。但是,拖拽进入的png文件保存在我的笔记本相同的目录。它把文字带进了细胞

""

shift + enter >图像现在显示在笔记本中。

FWIW