13

In PyCharm (community edition 2016.2.3), using anaconda2 + ubuntu 14.04, import matplotlib causes a signal 11 error during the debug mode. There is no problem when executing the script in release mode.

The python code:

import matplotlib as pt

The debug console:

Connected to pydev debugger (build 162.1967.10) GLib-GIO-Message: Using the 'memory' GSettings backend. Your settings will not be saved or shared with other applications. Backend Qt4Agg is interactive backend. Turning interactive mode on.

Process finished with exit code 139 (interrupted by signal 11: SIGSEGV)

nbro
  • 15,395
  • 32
  • 113
  • 196
user155322
  • 717
  • 3
  • 8
  • 17

7 Answers7

15

A bit late but it might help some googler.

Qt can cause this Problem. PyCharm runs with --qt-support=auto by default. If you have python bindings for Qt4 and Qt5 installed the auto function might not choose the correct version of Qt. Try to set the correct Qt bindings in PyCharm Settings (Build, Ex... -> Python Debugger - PyQt Compatible)

Setting from Auto to PyQt4 worked for me in conda environment, without removing anything.

FranzMueller
  • 151
  • 1
  • 3
  • "some googler" here . I notice that PySide2 is not in the list of options (though this is now the official Qt for Python). Do we have to wait for PyCharm to include it to use your solution or could there be a workaround? – James Paul Mason Oct 23 '18 at 14:24
7

I managed to get rid of the segfault and code 139, by unticking the Qt box in PyCharm Settings (Build, Ex... -> Python Debugger). My usage scenario: running some code with a remote interpreter. Needed matplotlib just for some figure.

Mircea
  • 954
  • 1
  • 13
  • 17
4

A quick and dirty work-around is to switch out the Qt backend for another one. For example, add this immediately after importing Matplotlib:

matplotlib.use('TkAgg')

You may want to use another one of the available backends.

If you have various modules with Matplotlib dependencies and you don't want to pollute your code, or if you're on a team, it would be better to change the backend in your matplotlibrc. You can find which matplotlibrc you're using with:

import matplotlib
print(matplotlib.matplotlib_fname())
crypdick
  • 16,152
  • 7
  • 51
  • 74
3

Mine worked after I removed pyqt5 bindings.

sudo apt-get remove python3-pyqt5

James D
  • 1,580
  • 1
  • 13
  • 9
1

Im my case it was due to the pandas package. Probably it was doing dataframes in threading (not supported?!).

To find your cause, do this:

gdb python
(gdb) script.py

(and when it crashes)

where

This will show the stack trace. In my case a missing file in numpy, which was fixed by:

pip install --upgrade pandas

Paamand
  • 626
  • 1
  • 6
  • 17
1

import matplotlib

then using this sentence... matplotlib.use('TkAgg')

Teddy Z.P.J.
  • 101
  • 3
  • 1
    This has already been provided as an answer: https://stackoverflow.com/a/51312698/8881141 – Mr. T Aug 01 '18 at 07:48
0

I had the same error message. I deleted anaconda and installed miniconda instead and reinstalled pycharm. The exit code 139 came both when I was running a python console as well as the debugging console.

Now when I import matplotlib, I still get the messages:

Backend Qt4Agg is interactive backend. Turning interactive mode on.

GLib-GIO-Message: Using the 'memory' GSettings backend. Your settings will not be saved or shared with other applications.

I guess thats not ideal but I am not getting an exit code and everything seems to work. It is a solution, but there must be a more robust way.