2

After many issues I've installed Librosa (https://github.com/librosa/librosa) on Linux Mint 18 Mate x64. When I want to run example script, e.g.: http://librosa.github.io/librosa/generated/librosa.feature.tempogram.html#librosa.feature.tempogram, it crashes with "Segmentation Fault" error:

$ 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

I've tried to debug it line-by-line and there is result:

$ 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

Probably there is some issue with matplotlib library and Qt (5.7.0). Moreover, I remember I had many issues when installing Librosa, including matplotlib, so it could be some installation issue. However, I don't know how to solve it. I hope somebody will have helpful clues for me.

1 Answer 1

3

Finally, I've solved this issue by installing these packages: sudo apt-get install tk-dev libpng-dev libffi-dev dvipng texlive-latex-base and reinstalling matplotlib using pip. I have also changed background in matplotlib on TkAgg. There is a beginning of a code with import statements:

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

Now it works perfectly.

Sign up to request clarification or add additional context in comments.

1 Comment

I had a similar issue. I just needed the matplotlib.use('TkAgg') line

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.