Issue
I was using a jupyter notebook inside VSCode and used ??
on the object to look the source code. The output showed :
Output exceeds the size limit. Open the full output data in a text editor
But when I click on it it opens the output in another window but everything is illegible.
What's going on here? What are those strange characters like esc[031m
? How can I get rid of them when viewing the full output data?
Solution
Those are ANSI escape codes- particularly ones for colouring.
If ANSI color support in edit buffer #38834 gets implemented, then this problem will sort of "go away" by default (though I imagine it could lead to different kinds of confusion).
The IPython configuration docs have a section on terminal colours:
InteractiveShell.colors
sets the colour of tracebacks and object info (the output from e.g.zip?
). It may also affect other things if the option below is set to'legacy'
. It has four case-insensitive values:'nocolor', 'neutral', 'linux', 'lightbg'
. The default is neutral, which should be legible on either dark or light terminal backgrounds. linux is optimised for dark backgrounds and lightbg for light ones.
See the rest of those docs for more info.
Ideally, the VS Code extension for IPython would strip out those ANSI escape sequences when showing the full output data in a text editor, but for now, you may be able to work around that by manual configuration by setting InteractiveShell.colors
to 'nocolor'
, or putting the following code cell at the start of your notebook: %colors nocolor
(see related docs here).
This problem has been brought up on the microsoft/vscode-jupyter
GitHub repo at least twice:
Truncated stacktraces illegible in text editor #10467
(closed pointing to another issue ticket: Output truncated with no way to view all output in the notebook itself #7096)
Error traces opened in text editor are not readable #11279
(closed as a duplicate of #10467)
Answered By - starball
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.