tornadoweb / tornado

Tornado is a Python web framework and asynchronous networking library, originally developed at FriendFeed.
http://www.tornadoweb.org/
Apache License 2.0
21.75k stars 5.5k forks source link

windows: No supported color terminal library #2013

Closed bdarnell closed 7 years ago

bdarnell commented 7 years ago

Some windows users are reporting "No supported color terminal library" errors at startup (the reports so far are by jupyter users; I don't know whether there's something about jupyter that is linked to this error or if that's just a large source of tornado-on-windows users). It looks like this can occur if colorama is installed but colorama.init has not been called.

Source: https://stackoverflow.com/questions/43443974/no-supported-color-terminal-library-python-jupyter

CC @mivade

mivade commented 7 years ago

Hmm, I'm not sure why I never encountered this problem. I'll take a look at it.

Do you have any ideas about a good way of testing this on appveyor?

bdarnell commented 7 years ago

If my analysis is right, then simply adding pip install colorama to appveyor.yml would be enough to trigger a failure when tornado.testing.main sets up logging.

mivade commented 7 years ago

Evidently, Jupyter is using colorama internally and ends up monkeypatching sys.stderr. If I start up an IPython terminal, I see this:

In [1]: import sys

In [2]: sys.stderr
Out[2]: <colorama.ansitowin32.StreamWrapper at 0x3e1b240>

This causes line 149:

elif sys.stderr is getattr(colorama, 'wrapped_stderr', object()):

to give False which then raises the error.

den-run-ai commented 7 years ago

for anyone who needs immediate fix (also mentioned in SO): pip install tornado==4.4.3

takluyver commented 7 years ago

Thanks!

For reference, ipython (the terminal interface, which doesn't use tornado) uses colorama on Windows to generate coloured output. jupyter notebook, which runs the notebook web server (built on tornado) does not use colorama, as far as I recall. Most Jupyter users on Windows will have colorama installed for IPython, though. Let me know if I can provide any more information from the Jupyter side.

mivade commented 7 years ago

@takluyver I'd be happy if you had any good suggestions about automating testing of this on appveyor (it's not clear to me if that's possible without having separate test instances with and without colorama present).

takluyver commented 7 years ago

You could combine that dimension with an existing dimension in the test matrix - e.g. install colorama when running the tests on a 64-bit architecture, but not a 32-bit architecture. It's theoretically messy, but in practice I think that when one group fails, it will usually be easy to see which difference is responsible.