ValueError: need more than 1 value to unpack
edwinhu opened this issue · comments
I'm seeing this error:
In [2]: import matplotlib.pyplot as plt
...: plt.plot([1,2,3,4])
...: plt.ylabel('some numbers')
...: plt.show()
...:
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
<ipython-input-2-a1c4f0c7307c> in <module>()
2 plt.plot([1,2,3,4])
3 plt.ylabel('some numbers')
----> 4 plt.show()
/home/hue/anaconda2/lib/python2.7/site-packages/matplotlib/pyplot.pyc in show(*args, **kw)
242 """
243 global _show
--> 244 return _show(*args, **kw)
245
246
/home/hue/bin/itermplot/itermplot.pyc in show()
93 figmanager = Gcf.get_active()
94 if figmanager is not None:
---> 95 figmanager.show()
96 else:
97 for manager in Gcf.get_all_fig_managers():
/home/hue/bin/itermplot/itermplot.pyc in show(self)
205 data = io.BytesIO()
206 self.canvas.print_figure(data, facecolor='none',
--> 207 edgecolor='none', transparent=True)
208 imgcat(data.getbuffer())
209
/home/hue/anaconda2/lib/python2.7/site-packages/matplotlib/backend_bases.pyc in print_figure(self, filename, dpi, facecolor, edgecolor, orientation, format, **kwargs)
2230 orientation=orientation,
2231 bbox_inches_restore=_bbox_inches_restore,
-> 2232 **kwargs)
2233 finally:
2234 if bbox_inches and restore_bbox:
/home/hue/bin/itermplot/itermplot.pyc in print_pdf(self, filename, **kwargs)
172
173 if 'rv' in os.getenv('ITERMPLOT'):
--> 174 self.reverse()
175
176 image_dpi = kwargs.get('dpi', 72) # dpi to use for images
/home/hue/bin/itermplot/itermplot.pyc in reverse(self, **kwargs)
147 for obj in self.figure.findobj():
148 if not obj in seen:
--> 149 modify(obj)
150 seen.add(obj)
151
/home/hue/bin/itermplot/itermplot.pyc in modify(c)
140 if not fcset:
141 c = obj.get_color()
--> 142 obj.set_color(revvideo(c))
143 except AttributeError as e:
144 pass
/home/hue/bin/itermplot/itermplot.pyc in revvideo(x)
57 return np.array([rev(el) for el in x])
58 else:
---> 59 return rev(x)
60
61 def imgcat(data, lines=-1):
/home/hue/bin/itermplot/itermplot.pyc in rev(c)
48 return (1.0 - r, 1.0 - g, 1.0 - b, a)
49 else:
---> 50 r, g, b = c
51 return (1.0 - r, 1.0 - g, 1.0 - b, 1.0)
52
ValueError: need more than 1 value to unpack
hi! i'm getting the same issue.
Thanks for sharing this project @daleroberts !
I'm also getting the same error above when I run @edwinhu's example code in ptpython.
I have the following error when I run in bpython:
Traceback (most recent call last):
File "", line 1, in
plt.show()
File "/Users/tw/miniconda3/lib/python3.5/site-packages/matplotlib/pyplot.py", line 252, in show
return _show(*args, **kw)
File "/Users/tw/itermplot/itermplot.py", line 95, in show
figmanager.show()
File "/Users/tw/itermplot/itermplot.py", line 208, in show
imgcat(data.getbuffer())
File "/Users/tw/itermplot/itermplot.py", line 82, in imgcat
sys.stdout.buffer.write(buf)
AttributeError: 'FakeOutput' object has no attribute 'buffer'
and the code actually works when I run in the basic python terminal, though it'd be great if it worked with other python interpreters as the basic one is pretty limiting. Thanks!
@edwinhu I've fixed the unpack bug by catching the exception and keeping the color "as is" if it can't parse it. Even though I couldn't reproduce the bug in matplotlib 1.5.3 with the code:
import matplotlib.pyplot as plt
plt.plot([1,2,3,4])
plt.ylabel('some numbers')
plt.show()
@Tiffany8 I'm going to look at the strange bpython
bug now...
Thanks for pointing out these bugs :)