click.echo() and click.secho() failed under ipython notebook

Created on 12 Aug 2017  路  6Comments  路  Source: pallets/click

I am using ipython notebook to run some of the terminal based code I wrote and found click.echo() and click.secho() will failed...

Any suggestion for a quick fix?

import click
click.echo('hello')

---------------------------------------------------------------------------
UnsupportedOperation                      Traceback (most recent call last)
<ipython-input-3-f575ef2d5c44> in <module>()
----> 1 click.echo('hello')

~/.virtualenvs/bernardyue.com/lib/python3.6/site-packages/click/utils.py in echo(message, file, nl, err, color)
    257 
    258     if message:
--> 259         file.write(message)
    260     file.flush()
    261 

UnsupportedOperation: not writable

Most helpful comment

Did you find a fix?

All 6 comments

Did you find a fix?

Any suggestions? I'm hitting the same issue.

This is a bug that was fixed in ipython. A workaround is on click master.

I'm having the same problem... I'm using Jupyter-notebook, python 3.5.

 258     if message:
 259         file.write(message)
 260     file.flush()

UnsupportedOperation: not writable

I believe this is causing issues ielsewhere:
https://github.com/enigmampc/catalyst/pull/181
https://github.com/enigmampc/catalyst/issues/261

Last "click" release according to https://github.com/pallets/click/releases was before fixing this issue
When do you plan next release with this fix so that installing with python pip will download release with this problem resolved?

In the meantime, the workaround is: pip install git+https://github.com/pallets/click. Be sure to do this in a virtualenv.

Was this page helpful?
0 / 5 - 0 ratings