Image 图像在非子目录中时不出现在ipython笔记本中
我正试图在ipython笔记本中使用代码从绝对路径Image 图像在非子目录中时不出现在ipython笔记本中,image,ipython,ipython-notebook,Image,Ipython,Ipython Notebook,我正试图在ipython笔记本中使用代码从绝对路径/Users/zhermes/[…]/image.png显示png图像 <img src="/Users/zhermes/[...]/image.png" style="width: 80%"> 如果我在本地目录中复制图像,即:/image.png,则此操作正常: <img src="image.png" style="width: 80%"> 同样,如果我有一个本地子目录,如/images/image.png 这
/Users/zhermes/[…]/image.png
显示png图像
<img src="/Users/zhermes/[...]/image.png" style="width: 80%">
如果我在本地目录中复制图像,即:/image.png
,则此操作正常:
<img src="image.png" style="width: 80%">
同样,如果我有一个本地子目录,如/images/image.png
这里怎么了
编辑:使用
IPython.display.Image
确实有效,但我更喜欢使用标记。你把url
和path
,browser
和kernel
,localhost
和server
搞混了。
试着想象一下服务器在AWS上,内核在rackspace上的超级计算机上,而chrome/firefox在笔记本电脑上
使用路径而不是URL,因此不起作用
使用一个URL,通过IPython的某种魔力,它被映射到当前工作/image.png
目录(在AWS上)
IPython.display.Image
在rackspace上获取图像
您在降价中要求的是访问您的
笔记本电脑上的文件。出于安全原因,这是不可能的,否则全互联网将访问您的全硬盘驱动器 我也遇到过类似的情况,我的图像或PDF不会出现在我的ipython笔记本上。Matt是对的,重要的是呈现笔记本的本地服务器可以访问您试图使用的文件
在我的例子中,我有一个笔记本项目的目录如下所示:
.
├── LICENSE.txt
├── README.md
├── images
│ ├── conductor.png
│ └── simple-position-sensor.png
├── notebooks
│ ├── performance-characteristics.ipynb
│ ├── position-sensor.ipynb
│ ├── resistance-temperature-detectors.html
│ ├── resistance-temperature-detectors.ipynb
│ └── resistance-temperature-detectors.slides.html
├── pdfs
│ └── linear-approximation.pdf
└── scripts
├── interp1d.py
└── numbered_eq.py
当我在笔记本文件夹中运行ipython notebook
时,图像不会呈现(标记或html)。它们确实使用IPython.display.Image
进行渲染,就像您的例子一样
解决方案是在包含ipython笔记本所需所有文件的工作目录上运行ipython notebook
。谢谢!在你的情况下,你指的是哪个目录?笔记本应在根目录
中运行?是的,在这种情况下,它是根目录
,但通常在包含笔记本和所有补充文件的文件夹中运行。
.
├── LICENSE.txt
├── README.md
├── images
│ ├── conductor.png
│ └── simple-position-sensor.png
├── notebooks
│ ├── performance-characteristics.ipynb
│ ├── position-sensor.ipynb
│ ├── resistance-temperature-detectors.html
│ ├── resistance-temperature-detectors.ipynb
│ └── resistance-temperature-detectors.slides.html
├── pdfs
│ └── linear-approximation.pdf
└── scripts
├── interp1d.py
└── numbered_eq.py