Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tkinter backend finishes with segmentation fault #3383

Closed
Gregor86 opened this issue Aug 18, 2014 · 4 comments
Closed

Tkinter backend finishes with segmentation fault #3383

Gregor86 opened this issue Aug 18, 2014 · 4 comments
Milestone

Comments

@Gregor86
Copy link

Hi,

I am very new here and hope, I haven't overseen anything about similar issues in the past. I am trying to use matplotlib with its Tkinter backend embedded into a GUI. Starting the application worked fine with earlier versions, but fails now on Ubuntu 14.04.
I just pulled matplotlib and installed it. I am currently standing on git hash fb27b4. My Tcl/Tk version is 8.6.

Here is my Application code:

import matplotlib
import Tkinter 
matplotlib.use('TkAgg')
print matplotlib.__version__
import matplotlib.pyplot as plt
from numpy import sin, linspace
print Tkinter.__version__
print Tkinter.TclVersion
print Tkinter.Tcl().eval("info tclversion")

x = linspace(0,6,1000)
fig, ax = plt.subplots(1,1)
ax.plot(x, sin(x), label="$f =$sin")
plt.show()

Why the print-statements? If I omit them, my application crashes with a Segmentation fault. If I leave them in, I get the following stack trace:

Exception in Tkinter callback
Traceback (most recent call last):
File "/usr/lib/python2.7/lib-tk/Tkinter.py", line 1489, in __call__
       return self.func(*args)
File "/home/optimi/bzfhende/.local/lib/python2.7/site-packages/matplotlib-1.5.x-py2.7-linux-x86_64.egg/matplotlib/backends/backend_tkagg.py", line 278, in resize
self.show()
 File "/home/optimi/bzfhende/.local/lib/python2.7/site-packages/matplotlib-1.5.x-py2.7-linux-x86_64.egg/matplotlib/backends/backend_tkagg.py", line 350, in draw
tkagg.blit(self._tkphoto, self.renderer._renderer, colormode=2)
File "/home/optimi/bzfhende/.local/lib/python2.7/site-packages/matplotlib-1.5.x-py2.7-linux-x86_64.egg/matplotlib/backends/tkagg.py", line 24, in blit
tk.call("PyAggImagePhoto", photoimage, id(aggimage), colormode, id(bbox_array))
TclError

The bbox_array is None here, maybe this is helpful to know.

I think it is related to a similar issue, but seemingly was not fixed in there, because I use the up-to-date matplotlib master. It is a TkAgg-issue, though: Switching to "Qt4Agg" in the use-command displays a pretty curve.

I appreciate your helpful comments on this and am happy to provide you with further information, if necessary.

@WeatherGod
Copy link
Member

let's ensure you built a completely clean matplotlib. Do a "git clean -fxd"
prior to "python setup.py install". Also, make sure your Tk development
libraries are up to date (at least at the same version of Tk). Do that
prior to rebuilding matplotlib.

On Mon, Aug 18, 2014 at 12:38 PM, Gregor86 notifications@github.com wrote:

Hi,

I am very new here and hope, I haven't overseen anything about similar
issues in the past. I am trying to use matplotlib with its Tkinter backend
embedded into a GUI. Starting the application worked fine with earlier
versions, but fails now on Ubuntu 14.04.
I just pulled matplotlib and installed it. I am currently standing on git
hash fb27b4. My Tcl/Tk version is 8.6.

Here is my Application code:

import matplotlib
import Tkinter
matplotlib.use('TkAgg')
print matplotlib.version
import matplotlib.pyplot as plt
from numpy import sin, linspace
print Tkinter.version
print Tkinter.TclVersion
print Tkinter.Tcl().eval("info tclversion")

x = linspace(0,6,1000)
fig, ax = plt.subplots(1,1)
ax.plot(x, sin(x), label="$f =$sin")
plt.show()

Why the print-statements? If I omit them, my application crashes with a
Segmentation fault. If I leave them in, I get the following stack trace:

Exception in Tkinter callback
Traceback (most recent call last):
File "/usr/lib/python2.7/lib-tk/Tkinter.py", line 1489, in call
return self.func(*args)
File "/home/optimi/bzfhende/.local/lib/python2.7/site-packages/matplotlib-1.5.x-py2.7-linux-x86_64.egg/matplotlib/backends/backend_tkagg.py", line 278, in resize
self.show()
File "/home/optimi/bzfhende/.local/lib/python2.7/site-packages/matplotlib-1.5.x-py2.7-linux-x86_64.egg/matplotlib/backends/backend_tkagg.py", line 350, in draw
tkagg.blit(self._tkphoto, self.renderer._renderer, colormode=2)
File "/home/optimi/bzfhende/.local/lib/python2.7/site-packages/matplotlib-1.5.x-py2.7-linux-x86_64.egg/matplotlib/backends/tkagg.py", line 24, in blit
tk.call("PyAggImagePhoto", photoimage, id(aggimage), colormode, id(bbox_array))
TclError

The bbox_array is None here, maybe this is helpful to know.

I think it is related to a similar issue
#2963, but seemingly was
not fixed in there, because I use the up-to-date matplotlib master. It is a
TkAgg-issue, though: Switching to "Qt4Agg" in the use-command displays a
pretty curve.

I appreciate your helpful comments on this and am happy to provide you
with further information, if necessary.


Reply to this email directly or view it on GitHub
#3383.

@tacaswell tacaswell added this to the v1.4.x milestone Aug 18, 2014
@Gregor86
Copy link
Author

@WeatherGod "git clean -fxd" did the job. I can now run both the example code above, and the backend now works again in my GUI. I didn't know I'd have to clean anything before rebuilding. I had a lot of output suggesting I was building from scratch.

Thanks a lot.

@tacaswell
Copy link
Member

You probably were rebuilding, but output from the c-extensions was left around. The c-source wasn't change so they were not rebuilt but the libraries changed underneath (which the python build tools had no way of knowing) hence the strange c-errors from way down the stack.

@Gregor86
Copy link
Author

@tacaswell Thank you for the clarification. Such issues need to be kept in mind all the time on an administrated work station, where you cannot prevent libraries from changing. I only started moving away from the system-wide matplotlib version because I had another bug I posted on StackOverflow with a broken system-wide library.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants