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

AttributeError: 'OutStream' object has no attribute 'buffer' .. Anaconda Jupiter Python 3.5 #19

Closed
makeyourowntextminingtoolkit opened this issue Oct 12, 2016 · 3 comments

Comments

@makeyourowntextminingtoolkit
Copy link

Hi - I'm using the Anaconda Python 3.5 distribution as many people do .. with all updates applied via conda updates.

The conda line_profiler doesn't work even though it is in the conda repos.

The profile looked interesting from a technical perspective so I installed it .. via pip install as it isn't in conda.

In a Jupyter notebook it seems to import ok:
import pprofile

Test function:

def work(n):
    print("hello")
    x = n * n
    print(x)
    pass

.. and call the code via the profiler:

profiler = pprofile.Profile()
with profiler:
    work(3)
profiler.print_stats()

But this fails with:

hello
9
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-9-6227c16eb3e5> in <module>()
      2 with profiler:
      3     work(3)
----> 4 profiler.print_stats()

/Users/tariq/anaconda3/lib/python3.5/site-packages/pprofile.py in print_stats(self)
    518         Returns None.
    519         """
--> 520         self.annotate(_reopen(sys.stdout, errors='replace'))
    521 
    522 class ProfileRunnerBase(object):

/Users/tariq/anaconda3/lib/python3.5/site-packages/pprofile.py in _reopen(stream, encoding, errors)
     64         # Also, I do not expect many 3.0 and 3.1 to be still used. Feel free to
     65         # report a bug if it raises.
---> 66         return codecs.getwriter(encoding)(stream.buffer, errors=errors)
     67 
     68 def _getFuncOrFile(func, module, line):

AttributeError: 'OutStream' object has no attribute 'buffer'

Any ideas?

I'd really like to have a profiler working inside the Jupyter notebook -- it's a constraint of developing an easy to use accessible tutorial/guide which avoids source code files and command lines ... in favour of the notebook.

ps .. dump_stats works .. so I guess this to do with stdout/stderr interactions with the notebook ...

profiler.dump_stats(filename="abc.txt")

@vpelletier
Copy link
Owner

Hello. This was reported and fixed as part of #16 . Reporter did not report on whether the fix was sufficient. Would you mind testing current master branch ?

@makeyourowntextminingtoolkit
Copy link
Author

hey vpelletier .. sadly I don't have the technical skills to do things like that .. all I do is install the anaconda python and update with conda update --all ....

@vpelletier
Copy link
Owner

I installed ipython-notebook and could confirm I get annotation output now. So I released it, along with a few other improvements, as 1.10.0 . Feel free to reopen or submit another bug if you still have issue with this release.

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