2016-08-21 116 views
0

在Linux Mint 18 Mate x64上安装了Librosa(https://github.com/librosa/librosa)之后,出现了很多问题。当我要运行示例脚本,例如:http://librosa.github.io/librosa/generated/librosa.feature.tempogram.html#librosa.feature.tempogram,它以“分段故障”错误崩溃:matplotlib运行示例Librosa脚本中的“分段错误”

$ python librosa-feature-tempogram-1.py 
/usr/local/lib/python2.7/dist-packages/matplotlib/backends/backend_qt5.py:140: Warning: g_main_context_push_thread_default: assertion 'acquired_context' failed 
    qApp = QtWidgets.QApplication([str(" ")]) 
Segmentation fault 

我试着逐条线调试和有结果:

$ python 
Python 2.7.12 (default, Jul 1 2016, 15:12:24) 
[GCC 5.4.0 20160609] on linux2 
Type "help", "copyright", "credits" or "license" for more information. 
>>> import librosa 

>>> # Visualize an STFT power spectrum 
... 
>>> import matplotlib.pyplot as plt 
>>> y, sr = librosa.load(librosa.util.example_audio_file()) 

>>> plt.figure(figsize=(12, 8)) 
/usr/local/lib/python2.7/dist-packages/matplotlib/backends/backend_qt5.py:140: Warning: g_main_context_push_thread_default: assertion 'acquired_context' failed 
    qApp = QtWidgets.QApplication([str(" ")]) 
Segmentation fault 

可能存在一些matplotlib库和Qt(5.7.0)的问题。此外,我记得我在安装Librosa时遇到了很多问题,包括matplotlib,所以它可能是一些安装问题。但是,我不知道如何解决它。我希望有人能为我提供有用的线索。 sudo apt-get install tk-dev libpng-dev libffi-dev dvipng texlive-latex-base和使用PIP重新安装matplotlib

回答

0

最后,我通过安装这些包解决了这个问题。我也改变了背景matplotlibTkAgg。有一个代码的开始与进口陈述:

import librosa 
import matplotlib 
matplotlib.use('TkAgg') 
import matplotlib.pyplot as plt 

现在它的工作完美。