我想在jupyter笔记本中包含图像.
如果我做了以下,它的工作原理:
from IPython.display import Image
Image("img/picture.png")
Run Code Online (Sandbox Code Playgroud)
但我想将图像包含在markdown单元格中,以下代码给出了404错误:

Run Code Online (Sandbox Code Playgroud)
我也试过了

Run Code Online (Sandbox Code Playgroud)
但我仍然得到同样的错误:
404 GET /notebooks/%22/home/user/folder/img/picture.png%22 (127.0.0.1) 2.74ms referer=http://localhost:8888/notebooks/notebook.ipynb
Run Code Online (Sandbox Code Playgroud) 我正在使用 google colab 并想嵌入一个 gif。有谁知道如何做到这一点?我正在使用下面的代码,它没有为笔记本中的 gif 设置动画。我希望笔记本具有交互性,以便人们无需运行即可看到代码的动画效果。
我找到了很多在 Google colab 中不起作用的方法。感兴趣的代码和 GIF 如下。
import matplotlib.pyplot as plt
import matplotlib.image as mpimg
img = mpimg.imread("/content/animationBrownianMotion2d.gif")
plt.imshow(img)
Run Code Online (Sandbox Code Playgroud)
我尝试了一些提供的解决方案。
import IPython
from IPython.display import Image
Image(filename='/content/animationBrownianMotion2d.gif')
Run Code Online (Sandbox Code Playgroud)
同样
import IPython
from IPython.display import Image
Image(filename='/content/animationBrownianMotion2d.gif',embed=True)
Run Code Online (Sandbox Code Playgroud)
但得到了错误,
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
<ipython-input-27-56bf6cd2b134> in <module>()
1 import IPython
2 from IPython.display import Image
----> 3 Image(filename='/content/animationBrownianMotion2d.gif',embed=True)
4
/usr/local/lib/python3.6/dist-packages/IPython/core/display.py in __init__(self, data, url, filename, format, embed, width, height, retina, unconfined, metadata)
1013
1014 if …Run Code Online (Sandbox Code Playgroud)