相关疑难解决方法(0)

"UserWarning: Matplotlib is currently using agg, which is a non-GUI backend, so cannot show the figure." when plotting figure with pyplot on Pycharm

I am trying to plot a simple graph using pyplot, e.g.:

import matplotlib.pyplot as plt
plt.plot([1,2,3],[5,7,4])
plt.show()
Run Code Online (Sandbox Code Playgroud)

but the figure does not appear and I get the following message:

UserWarning: Matplotlib is currently using agg, which is a non-GUI backend, so cannot show the figure.
Run Code Online (Sandbox Code Playgroud)

I saw in several places that one had to change the configuration of matplotlib using the following:

import matplotlib
matplotlib.use('TkAgg')
import matplotlib.pyplot as plt
Run Code Online (Sandbox Code Playgroud)

I did this, but then got an error message because it …

python matplotlib pycharm

34
推荐指数
10
解决办法
2万
查看次数

找不到tkinter的匹配分布

自从过去两天以来我一直坚持这个问题,我已经在堆栈和github上尝试了所有可能的解决方案.如果有人可以推荐,真的很棒.

我在CentOS Linux版本7.3.1611的虚拟环境中使用python 2.7.

我正在运行一个使用matplotlib.pyplot的脚本,并在运行时出现此错误

import  matplotlib.pyplot as plt
 File "/usr/local/packages/Python-2.7/lib/python2.7/lib-tk/Tkinter.py", line 39, in <module>
    import _tkinter # If this fails your Python may not be configured for Tk
ImportError: No module named _tkinter 
Run Code Online (Sandbox Code Playgroud)

我尝试使用 - 安装tkinter

 pip install tkinter and it gave this error 
Could not find a version that satisfies the requirement tkinter (from versions: )
No matching distribution found for tkinter
Run Code Online (Sandbox Code Playgroud)

然后我甚至安装 -

sudo yum install tk
sudo yum install tk-devel
sudo yum install tc 
Run Code Online (Sandbox Code Playgroud)

并说它已经安装了包 nothing …

python module tk-toolkit tkinter

20
推荐指数
2
解决办法
3万
查看次数

标签 统计

python ×2

matplotlib ×1

module ×1

pycharm ×1

tk-toolkit ×1

tkinter ×1