2016-08-21 50 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 

現在它的工作完美。