简体   繁体   English

Matplotlib Pyplot在Ubuntu 16.04上中断

[英]Matplotlib Pyplot breaks on Ubuntu 16.04

I am currently using Python 2.7 on Ubuntu 16.04 and would like the ability to plot figures using Matplotlib. 我目前在Ubuntu 16.04上使用Python 2.7,并希望能够使用Matplotlib绘制图形。 However, calling any sort of plot command causes the entire script to hang at that line. 但是,调用任何种类的plot命令都会导致整个脚本挂在该行。

** Note ** Before marking this as a duplicate question, please consider that this issue may not be related to the backend that I am using as I have tried every iteration of this solution that I have found on the internet. **注意**在将此问题标记为重复问题之前,请考虑该问题可能与我正在使用的后端无关,因为我尝试了在互联网上找到的该解决方案的每次迭代。

A simple script which illustrates my problem: 一个简单的脚本说明了我的问题:

#!/usr/bin/env python
import matplotlib
matplotlib.use('TkAgg')
from matplotlib import pyplot as plt
plt.interactive('True')


if __name__ == '__main__':

    print 'Hello World!'
    plt.figure()
    print 'Hello Again World!'

The output of the above script is: Hello World! 上面脚本的输出是:Hello World!

The script then hangs at the plt.figure() line, causes 100% cpu usage, and cannot be killed using Ctrl-C. 然后,脚本将挂在plt.figure()行,导致100%的CPU使用率,并且无法使用Ctrl-C将其杀死。 I use "kill" to kill that process. 我使用“ kill”杀死该进程。

I never figured out what caused my problem, but my (poor) solution was to reinstall Ubuntu 16.04 and then matplotlib. 我从未弄清楚是什么原因导致了我的问题,但我的(较差)解决方案是重新安装Ubuntu 16.04,然后重新安装matplotlib。 It is working fine now. 现在工作正常。

Thanks everyone! 感谢大家!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM