自拍偷在线精品自拍偷,亚洲欧美中文日韩v在线观看不卡

搞定Matplotlib運(yùn)行報(bào)錯(cuò) Usingagg,non-GUI backend

開發(fā) 后端
matplotlib是python繪圖這方面的權(quán)威,它能讓使用者很輕松地將數(shù)據(jù)圖形化,并且提供多樣化的輸出格式,于是決定對其進(jìn)行試用!

[[437992]]

最近想玩玩python的圖形處理模塊來進(jìn)行數(shù)據(jù)圖形顯示相關(guān)的開發(fā),目的是把服務(wù)器中的數(shù)據(jù)資源生成圖形(docker資源利用率展示不符合需求)。而matplotlib是python繪圖這方面的權(quán)威,它能讓使用者很輕松地將數(shù)據(jù)圖形化,并且提供多樣化的輸出格式,于是決定對其進(jìn)行試用!

matplotlib的安裝

使用pip命令安裝:

pip install –i https://pypi.tuna.tsinghua.edu.cn/simple matplotlib

為了提高安裝效率這里,使用清華鏡像。

本人python環(huán)境: win10 ,python 3.7.4

遇到的運(yùn)行問題

Matplotlib成功安裝后,在網(wǎng)上隨便找了段代碼來運(yùn)行

  1. import matplotlib.pyplot as plt 
  2. plt.plot([3,4,5]) 
  3. plt.ylabel('numbers'
  4. plt.show() 

 報(bào)錯(cuò)如下:

  1. UserWarning: Matplotlib is currently usingagg, which is a non-GUI backend, so cannot show the figure. plt.show() 

問題的解決方案

網(wǎng)上有很多解決方案,里面也有很多坑,最后匯總,通過以下兩點(diǎn)可以輕松運(yùn)行matplotlib實(shí)例

1. check 在安裝python時(shí),是否勾選了tcl/tk,如果沒有勾選上(此處浪費(fèi)了我大量時(shí)間debug)

搞定matplotlib運(yùn)行報(bào)錯(cuò) usingagg,non-GUI backend

2.加入如下代碼

  1. import matplotlib 
  2.  
  3. matplotlib.use('TkAgg'

 再次運(yùn)行,成功!如下圖所示:

搞定matplotlib運(yùn)行報(bào)錯(cuò) usingagg,non-GUI backend

 

責(zé)任編輯:姜華 來源: 今日頭條
相關(guān)推薦

2011-05-06 10:32:02

指點(diǎn)桿

2009-12-03 11:37:56

Suse Linux

2021-01-04 09:19:06

WindowsLinuxGUI程序

2015-08-03 14:02:37

Windows 10升級

2021-06-02 09:45:21

WSLgWindows 10Linux

2021-06-09 13:22:54

WSLWindowsLinux

2025-02-10 04:00:00

Linux進(jìn)程Python

2021-05-26 13:34:21

Windows 10Linux GUI應(yīng)用程序

2009-10-27 15:09:04

2022-09-14 10:26:14

架構(gòu)微服務(wù)前端

2021-12-10 08:13:02

MatplotlibpythonAPI

2020-03-19 09:00:00

泛型代碼復(fù)用率程序運(yùn)行性能

2024-06-11 00:00:00

前端輪播圖硬件

2024-12-03 15:50:00

Matplotlib可視化

2016-09-22 16:06:21

微服務(wù)架構(gòu)RPC框架

2022-09-16 08:04:25

阿里云權(quán)限網(wǎng)絡(luò)

2022-02-12 11:00:33

FTP網(wǎng)絡(luò)協(xié)議文件傳輸

2009-06-16 09:09:59

LinuxWebminGUI

2009-12-11 15:37:58

Linux日志處理

2017-05-11 15:01:43

Androidweb布局
點(diǎn)贊
收藏

51CTO技術(shù)棧公眾號