脚本之家,脚本语言编程技术及教程分享平台!
分类导航

Python|VBS|Ruby|Lua|perl|VBA|Golang|PowerShell|Erlang|autoit|Dos|bat|

服务器之家 - 脚本之家 - Python - jupyter notebook中图片显示不出来的解决

jupyter notebook中图片显示不出来的解决

2021-09-27 00:13淡淡梅汁 Python

这篇文章主要介绍了jupyter notebook中图片显示不出来的解决操作,具有很好的参考价值,希望对大家有所帮助。一起跟随小编过来看看吧

报错:

D:\Program Files\Anaconda3\lib\site-packages\matplotlib\figure.py:445: UserWarning: Matplotlib is currently using module://ipykernel.pylab.backend_inline, which is a non-GUI backend, so......

解决方法:

  1. import matplotlib
  2. matplotlib.use('TkAgg')
  3. import matplotlib.pyplot as plt

补充:Jupyter Notebook 插入图片的几种方法

一、通过HTML方式

插入本地图片

使用 <img src> 语句插入本地图片,其中src为图片路径,可以是相对路径或绝对路径。

  1. <img src="./jupyter_logo.png", width=320, heigth=240>

上述语句为插入当前目录下名为“jupyter_logo.png”的图片,宽度设为320, 高度设为240。

jupyter notebook中图片显示不出来的解决

如果不指定维度,则为原图大小。

插入网络图片

<img src> 语句同样可以插入网络图片。

  1. <img src="http://jupyter.org/assets/main-logo.svg", width=320, heigth=240>

jupyter notebook中图片显示不出来的解决

二、通过Markdown格式插入图片

插入图片的格式为:![图片标签](图片源 src),其中,在图像显示错误的时候会显示图像标签的内容。

插入本地图片

需将图片源换成图片的本地路径,可以是绝对路径或相对路径。

  1. ![jupyter](./jupyter_logo.png)

jupyter notebook中图片显示不出来的解决

如果我们将图片路径设置为一个不存在的路径,

  1. ![jupyter](./jupyter_logoxxx.png)

则会显示图片标签,

jupyter notebook中图片显示不出来的解决

插入网络图片

需将图像源设为图像网址,

  1. ![jupyter](http://jupyter.org/assets/main-logo.svg)

显示如下

jupyter notebook中图片显示不出来的解决

以上为个人经验,希望能给大家一个参考,也希望大家多多支持我们。如有错误或未考虑完全的地方,望不吝赐教。

原文链接:https://blog.csdn.net/qq_42273575/article/details/88119438

延伸 · 阅读

精彩推荐