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


当前回答

(过时的)

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

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

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

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

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

其他回答

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

""

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

FWIW

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

我把我的mypic。png

/root/Images/mypic.png

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

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

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

首先确保你在ipython notebook单元格中的markdown编辑模型中

这是其他人提出的方法的替代方法<img src="myimage.png">:

![title](img/picture.png)

如果没有标题,它似乎也有效:

![](img/picture.png)

注意,路径中不应该有引号。不确定这是否适用于有空格的路径!

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

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

(过时的)

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

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

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

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

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