Segmentation fault when importing pyqtgraph on Python 3.52 (Linux Mint)

788 views
Skip to first unread message

Armen Levonian

unread,
Sep 13, 2017, 5:31:27 PM9/13/17
to pyqtgraph
So for some reason pyqtgraph started giving the segmentation fault immediately upon importing the module.
The strange thing was that after I installed it today for Python 3.52 and after installing all the other deps, it was working perfectly, including running examples for PyQt5.

The other strange thing is that it is working perfectly for Python 2.7 (with PyQt4).

...and I am having exactly the same problem but only in Python 3.52. I did the "gdb Python3" step and it reported the same string issue...

...
$ gdb python3
GNU gdb (Ubuntu 7.11.1-0ubuntu1~16.5) 7.11.1
Copyright (C) 2016 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
Find the GDB manual and other documentation resources online at:
For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from python3...(no debugging symbols found)...done.
(gdb) run
Starting program: /usr/bin/python3 
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
Python 3.5.2 (default, Nov 17 2016, 17:05:23) 
[GCC 5.4.0 20160609] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import pyqtgraph

Program received signal SIGSEGV, Segmentation fault.
strlen () at ../sysdeps/x86_64/strlen.S:106
106 ../sysdeps/x86_64/strlen.S: No such file or directory.
(gdb)

...


I think the only thing I did between it working and giving a seg fault is that Mint update updated google Cloud SDK, but I cannot fathom what relationship that has except that I noticed it generated an error (did not note it).

Sebastian Höfer

unread,
Sep 14, 2017, 6:10:51 AM9/14/17
to pyqtgraph
Hello Armen,

it's hard to tell from just one error message, but it smells of a version mismatch in the libraries. The answers in the stackoverflow thread guessed that, too.
So one solution could be to update all packages (Python, Qt, PyQt, PyQtGraph) to their newest version (with apt-get) and take care that the (Python-)versions match! But I remember that was a pain to do under Ubuntu, because it insistet on using an old version of Python for it's internal scripts and a lot of the included packages are not up-to-date. So, I had to get some packages from alternative sources.

My recommended solution would be to use a virtual environent, where you can configure your Python exactly to your needs. I usually use Anaconda (https://www.anaconda.com/download/) and create a clean environment for each project. I haven't testet the Linux version, but it should be worth a try. There are also other Python-distributions and virtual environments, this is just what I'm going with.

I hope it helps!

Regards
Sebastian

Larry Byars

unread,
Feb 14, 2018, 12:53:50 PM2/14/18
to pyqtgraph
Hello. I decided to do some exploration of pyqtgraph today on my Xubuntu 16.04 system with python 3.5.2 and PyQt5. I tried several methods of installing pyqtgraph but in all cases when I started python3 and typed "import pyqtgraph" I got a Segmentation fault and reported here and elsewhere. Being a stubborn sort (you get that way when you've been programming for 50 years) I couldn't give up. As I was looking at some of the examples I was a bit astonished to see code like:

>>>  from pyqtgraph.Qt import QtCore, QtGui

rather than what I was used to in my learning about PyQT5. So I started python3 again and typed:
>>>  import PyQt5
>>>  import pyqtgraph

and guess what? It didn't crash! I was able to run the examples and learn a bit about the workings of pyqtgraph. One additional note, in trying to execute the fractal.py example I got errors about mats = reduce(matmul, mats) and discovered that reduce is no longer native for python 3 but needs to be imported from functools. Small change to fractal.py and it works.

Anyway, I hope this discovery will help others that are trying to explore pyqtgraph but not getting past the first step. Probably someone with much more experience than me (at least with python) will have to figure out why this works. 

Suggestions to us Anaconda are not very appealing to me since I'm developing some code that will be used by others and I don't want them to have to install Anaconda. 

I haven't tried this on  in a Windows environment (yet) where my application is currently deployed. I'll have to see if pyqtgraph provides me the right functionality to be able to integrate it with my other pyqt5 code.

But on first look, I'm impressed with the functionality of pyqtgraph. Good work!

Luke Campagnola

unread,
Feb 14, 2018, 1:55:57 PM2/14/18
to pyqt...@googlegroups.com
Hi Larry,

I believe the bug you are seeing is in the PyQt4 packages for Python 3 in ubuntu. On one of my machines (Mint 18), I get a segmentation fault just by importing PyQt4.QtGui from Python 3:

$ python3

Python 3.5.2 (default, Nov 17 2016, 17:05:23)
[GCC 5.4.0 20160609] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import PyQt4.QtGui
Segmentation fault

On another machine (Ubuntu 17.10), I cannot reproduce the bug, so I hope this has already been fixed upstream. PyQt5 works on all systems I have tested.

The reason importing PyQt5 fixes the issue with pyqtgraph is that it forces pyqtgraph to use PyQt5, rather than importing PyQt4 on its own.


Luke

--
You received this message because you are subscribed to the Google Groups "pyqtgraph" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pyqtgraph+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/pyqtgraph/7dfc2615-201f-45ce-b576-a540b582a8aa%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages