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

Broken in jupyter console #51

Open
lukelbd opened this issue Mar 3, 2022 · 1 comment
Open

Broken in jupyter console #51

lukelbd opened this issue Mar 3, 2022 · 1 comment

Comments

@lukelbd
Copy link

lukelbd commented Mar 3, 2022

I get the following traceback in a jupyter console session with the itermplot==0.5 version recommended in the readme. Using pip install --upgrade itermplot to version 0.331 also does not help.

In [1]: fig, ax = plt.subplots()
   ...: fig.show()
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
Input In [1], in <module>
      1 fig, ax = pplt.subplot()
----> 2 fig.show()

File ~/miniconda3/lib/python3.9/site-packages/matplotlib/figure.py:2364, in Figure.show(self, warn)
   2360     raise AttributeError(
   2361         "Figure.show works only for figures managed by pyplot, "
   2362         "normally created by pyplot.figure()")
   2363 try:
-> 2364     self.canvas.manager.show()
   2365 except NonGuiException as exc:
   2366     if warn:

File ~/miniconda3/lib/python3.9/site-packages/itermplot/__init__.py:298, in ItermplotFigureManager.show(self)
    295     data = self.animate(loops, outfile)
    297 if hasattr(data, "getbuffer"):
--> 298     imgcat(data.getbuffer(), fn)
    299 else:  # Python 2
    300     imgcat(data.getvalue(), fn)

File ~/miniconda3/lib/python3.9/site-packages/itermplot/__init__.py:124, in imgcat(data, fn)
    122     sys.stdout.buffer.write(buf)
    123 else:
--> 124     sys.stdout.write(buf)
    125 sys.stdout.flush()
    127 print()

File ~/miniconda3/lib/python3.9/site-packages/ipykernel/iostream.py:513, in OutStream.write(self, string)
    503 """Write to current stream after encoding if necessary
    504
    505 Returns
   (...)
    509
    510 """
    512 if not isinstance(string, str):
--> 513     raise TypeError(
    514         f"write() argument must be str, not {type(string)}"
    515     )
    517 if self.echo is not None:
    518     try:

TypeError: write() argument must be str, not <class 'bytes'>
@dthirst
Copy link

dthirst commented Sep 20, 2022

experiencing the same issue

edit:
adding matplotlib inline before importing matplotlib fixed the issue for me:

%matplotlib inline
import matplotlib.pyplot as plt

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

2 participants