我开始严重依赖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?


当前回答

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

""

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

FWIW

其他回答

对于那些寻找图像文件放在Jupyter机器上的位置,以便可以从本地文件系统显示它的人。

我把我的mypic。png

/root/Images/mypic.png

(这是图像文件夹,显示在Jupyter在线文件浏览器)

在这种情况下,我需要把下面的行Markdown单元格,使我的照片显示在记事本:

![My Title](Images/mypic.png)

明克的答案是正确的。

然而,我发现图像在打印视图中出现了损坏(在我的Windows机器上,在Chrome浏览器中运行IPython版本0.13.2的Anaconda发行版)

解决方法是使用<img src="../files/image.png">代替。

这使得图像在打印视图和正常的iPython编辑视图中都正确显示。

更新:当我升级到iPython v1.1.0时,不再需要这个解决方案,因为打印视图不再存在。事实上,您必须避免这种解决方法,因为它会阻止nbconvert工具查找文件。

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

""

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

FWIW

(过时的)

IPython/Jupyter现在支持扩展模块,可以通过复制粘贴或拖放插入图像。

https://github.com/ipython-contrib/IPython-notebook-extensions

拖放扩展似乎在大多数浏览器中工作

https://github.com/ipython-contrib/IPython-notebook-extensions/tree/master/nbextensions/usability/dragdrop

但是复制粘贴只能在Chrome中使用。

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