运行示例Librosa scrip的matplotlib中的“分段错误”

2024-04-19 17:35:27 发布

您现在位置:Python中文网/ 问答频道 /正文

在许多问题之后,我在linuxmint18matex64上安装了Librosa(https://github.com/librosa/librosa)。当我想运行示例脚本时,例如:http://librosa.github.io/librosa/generated/librosa.feature.tempogram.html#librosa.feature.tempogram,它会崩溃,并出现“Segmentation Fault”错误:

$ 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

我试着逐行调试,结果是:

^{pr2}$

matplotlib库和Qt(5.7.0)可能存在一些问题。此外,我记得我在安装Librosa时遇到了很多问题,包括matplotlib,所以可能是安装问题。但是,我不知道怎么解决它。我希望有人能给我一些有用的线索。在


Tags: pyhttpsgithub脚本comhttp示例matplotlib
1条回答
网友
1楼 · 发布于 2024-04-19 17:35:27

最后,我通过安装这些包来解决这个问题:sudo apt-get install tk-dev libpng-dev libffi-dev dvipng texlive-latex-base并使用pip重新安装matplotlib。我还在TkAgg上的matplotlib中更改了背景。有一个带有import语句的代码开头:

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

现在它完美地工作了。在

相关问题 更多 >