Skip to content

All attempts to plot fail with "OverflowError: Python int too large to convert to C long" #7633

Closed

Description

@akkana

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.

Minimal test program:

import pylab

distances = [0, 0.0011970407617050934, 0.0050796062254631295, 0.007303941153223762, 0.007303941153223762, 0.008232870398475445, 0.008232870398475445, 0.012806461740481582, 0.016651523629144134, 0.021047330616832543]
elevations = [6404.2, 6410.76, 6400.92, 6410.76, 6423.88, 6423.88, 6453.41, 6410.76, 6427.17, 6420.6]
pylab.plot(distances, elevations)
pylab.show()

(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.

Activity

  1. efiring commented on Dec 18, 2016

    @efiring
    Member

    Would you provide a full traceback, please? What hardware are you running on? Is the system 32-bit or 64-bit?

  2. akkana commented on Dec 18, 2016

    @akkana
    Author

    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

  3. akkana commented on Dec 18, 2016

    @akkana
    Author

    The system is 32-bit. The hardware is a Lenovo X201.

  4. akkana commented on Dec 18, 2016

    @akkana
    Author

    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.

  5. QuLogic commented on Dec 18, 2016

    @QuLogic
    Member

    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.

  6. added this to the milestone on Dec 18, 2016
  7. added a commit that references this issue on Dec 18, 2016
    a91559b
  8. self-assigned this
    on Dec 18, 2016
  9. modified the milestones: , on Dec 18, 2016
  10. cgohlke commented on Dec 18, 2016

    @cgohlke
    Contributor

    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.

  11. sandrotosi commented on Dec 18, 2016

    @sandrotosi
    Contributor

    @tacaswell do you plan to include this in 2.0.0rc2?

  12. tacaswell commented on Dec 18, 2016

    @tacaswell
    Member

    @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?

  13. sandrotosi commented on Dec 18, 2016

    @sandrotosi
    Contributor

    nice thanks!

    i dont see any patch to the tk modules in the python2.7 interpreter packaging repo

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions