我一直在尝试在 Jupyter notebook 中显示 gif,但遇到了一些麻烦。我一直收到一个空白图像文件。
我尝试使用来自 this GitHub repository 的 html .
![wignerfunction][1](../gifs/wigner_rotation_animate.gif "wigner")
和
from IPython.display import Image
Image(url='example.gif')
到目前为止,以上方法均无效。
谢谢
最佳答案
I've been trying to display a gif in Jupyter notebook and have had some trouble.
要在笔记本中显示 gif,您可以像这样在 Markdown 单元格上使用内联标记:
ipynb notebook文件所在文件夹的相对引用:
![SegmentLocal](191px-Seven_segment_display-animated.gif "segment")
ipynb 笔记本文件所在文件夹的子文件夹图像中的相对引用:
![SegmentLocal](images/191px-Seven_segment_display-animated.gif "segment")
无论笔记本文件的位置如何,从根文件夹绝对引用:
![SegmentLocal](/Users/username/some-folder/191px-Seven_segment_display-animated.gif "segment")
URL 引用(应该在您的笔记本中开箱即用):
![ChessUrl](https://upload.wikimedia.org/wikipedia/commons/7/71/ChessPawnSpecialMoves.gif "chess")
例如,由于堆栈溢出也使用 markdown,如果最后提到的行恰好给出,最后一行带有 url 引用:![ChessUrl](https://upload.wikimedia.org/wikipedia/commons/7/71/ChessPawnSpecialMoves.gif "chess")
,但未作为代码引用计算得出:
也应该显示在您的 jupyter notebook 中。现在,如果您可以看到最后一个,但无法从引用的本地文件中看到它,则很可能是 gif 损坏、权限问题或文件路径不正确。
关于python - 如何在 Jupyter notebook 中嵌入 gif?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51527868/