You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
All attempts to plot fail with "OverflowError: Python int too large to convert to C long" #7633
To help us understand and resolve your issue please check that you have provided
the information below.
Matplotlib version, Python version and Platform (Windows, OSX, Linux ...)
Platform: Debian Testing, using the python 2.7 (2.7.11-2 when I first started seeing this, just upgraded to 2.7.13rc1 but the problem still exists). I have this problem with the 1.5.3 on debian testing, but I also tried a virtualenv with pip install --pre matplotlib, which pulled in 2.0.0rc1, and I see the same problem.
Debian stable, with matplotlib 1.4.2, works fine, as did Debian testing until recently.
How did you install Matplotlib and Python (pip, anaconda, from source ...)
See above: Debian package and virtualenv.
If possible please supply a Short, Self Contained, Correct, Example
that demonstrates the issue i.e a small piece of code which reproduces the issue
and can be run with out any other (or as few as possible) external dependencies.
(Please let me know if you want a non-pylab example. I see it with straight matplotlib too.)
If this is an image generation bug attach a screenshot demonstrating the issue.
If this is a regression (Used to work in an earlier version of Matplotlib), please
note where it used to work.
It worked as recently as a month ago on Debian testing, but sorry, I don't know what matplotlib version that was since I didn't know it was going to stop working.
Exception in Tkinter callback
Traceback (most recent call last):
File "/usr/lib/python2.7/lib-tk/Tkinter.py", line 1545, in call
return self.func(*args)
File "/usr/lib/python2.7/dist-packages/matplotlib/backends/backend_tkagg.py", line 283, in resize
self.show()
File "/usr/lib/python2.7/dist-packages/matplotlib/backends/backend_tkagg.py", line 355, in draw
tkagg.blit(self._tkphoto, self.renderer._renderer, colormode=2)
File "/usr/lib/python2.7/dist-packages/matplotlib/backends/tkagg.py", line 26, in blit
_tkagg.tkinit(tk.interpaddr(), 1)
OverflowError: Python int too large to convert to C long
I just tried setting up a venv where I downgraded all the way to 1.4.2 (since I know it works there on debian stable) but that doesn't tell me much; it doesn't hit the overflow error, but it exits without showing a window. The same thing happens if I try 1.5.0 or 1.5.1. Maybe there's something in the virtualenv that matplotlib needs and isn't getting? (I'm pretty new to virtualenvs.) 1.5.2 is the first version where I see the OverflowError. It might also be worth mentioning that in 1.5.2, 1.5.3 and the --pre version (sorry, didn't record it, I think it was 2.0-something?) where it prints the error, it shows a window but the window is blank. In these earlier versions inside the venv, I don't get a window, it just exits. In Debian Stable 1.4.2, everything works as expected, a window comes up with a plot in it.
The TkAgg backend is using an integer to hold a pointer; this is unfortunate and bound to cause trouble, except it will be rather random as it depends on whether the pointer is too large or not. On 32-bit systems, this will occur quite a bit more often since integers are smaller.
FWIW, I think it's issues like these (extensions storing pointers in signed integers etc) why the official 32-bit Python distributions for Windows do not allow to use the address space above 2 GB. See http://bugs.python.org/issue1449496.
Activity
efiring commentedon Dec 18, 2016
Would you provide a full traceback, please? What hardware are you running on? Is the system 32-bit or 64-bit?
akkana commentedon Dec 18, 2016
Sorry, of course I should have provided that.
Exception in Tkinter callback
Traceback (most recent call last):
File "/usr/lib/python2.7/lib-tk/Tkinter.py", line 1545, in call
return self.func(*args)
File "/usr/lib/python2.7/dist-packages/matplotlib/backends/backend_tkagg.py", line 283, in resize
self.show()
File "/usr/lib/python2.7/dist-packages/matplotlib/backends/backend_tkagg.py", line 355, in draw
tkagg.blit(self._tkphoto, self.renderer._renderer, colormode=2)
File "/usr/lib/python2.7/dist-packages/matplotlib/backends/tkagg.py", line 26, in blit
_tkagg.tkinit(tk.interpaddr(), 1)
OverflowError: Python int too large to convert to C long
akkana commentedon Dec 18, 2016
The system is 32-bit. The hardware is a Lenovo X201.
akkana commentedon Dec 18, 2016
I just tried setting up a venv where I downgraded all the way to 1.4.2 (since I know it works there on debian stable) but that doesn't tell me much; it doesn't hit the overflow error, but it exits without showing a window. The same thing happens if I try 1.5.0 or 1.5.1. Maybe there's something in the virtualenv that matplotlib needs and isn't getting? (I'm pretty new to virtualenvs.) 1.5.2 is the first version where I see the OverflowError. It might also be worth mentioning that in 1.5.2, 1.5.3 and the --pre version (sorry, didn't record it, I think it was 2.0-something?) where it prints the error, it shows a window but the window is blank. In these earlier versions inside the venv, I don't get a window, it just exits. In Debian Stable 1.4.2, everything works as expected, a window comes up with a plot in it.
QuLogic commentedon Dec 18, 2016
The TkAgg backend is using an integer to hold a pointer; this is unfortunate and bound to cause trouble, except it will be rather random as it depends on whether the pointer is too large or not. On 32-bit systems, this will occur quite a bit more often since integers are smaller.
Here is a related issue in Pillow, except that a long time ago, the type was changed from an int to a long.
Matplotlib is still using an int though, so that needs to be fixed.
Use correct type for Tk addresses.
cgohlke commentedon Dec 18, 2016
FWIW, I think it's issues like these (extensions storing pointers in signed integers etc) why the official 32-bit Python distributions for Windows do not allow to use the address space above 2 GB. See http://bugs.python.org/issue1449496.
sandrotosi commentedon Dec 18, 2016
@tacaswell do you plan to include this in 2.0.0rc2?
tacaswell commentedon Dec 18, 2016
@sandrotosi Yes, I have sunk most of my morning into understanding this will enough to merge @QuLogic 's patch 😉 to merge it and then tag rc2.
Does debian do any patching of python's tk modules?
sandrotosi commentedon Dec 18, 2016
nice thanks!
i dont see any patch to the tk modules in the python2.7 interpreter packaging repo