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 …
自从过去两天以来我一直坚持这个问题,我已经在堆栈和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 …