I'm using VSCode for coding Python. The problem is VSCode prints any output (Errors, Warning and ...) in the same format and color.
Is there any extension or tools to manage it? for example like PyCharm print errors with Red color, warning with yellow and so on?
VSCode comes with in-built color themes which can be used to change the colors of the editor and the terminal. For changing the color theme press Ctrl + K + T in windows/ubuntu or CMD + K + T on mac.
That's not a problem with vscode, but general thing with bash/powershell/cmd (kind reminder that the console that vscode uses, is driven by powershell/bash).
I think I managed to find a fine solution/mitigation for your problem. I found this answer which gave nice results.
TBH I don't like this IPython look. Never did. After some research I came up with this improved code
import sys
from IPython.core.ultratb import ColorTB
sys.excepthook = ColorTB()
Which colored well for me on Windows: But adding this code each time will be... Very annoying. We should find a way to make it run on any .py on vscode.
I found a way to make any Python file run some line of code before running any script.
Go to your python PythonXY\Lib\site-packages
where XY is your python version. Add file named exactly sitecustomize.py
, and add our improved script.
Test it by printing non-existent variable print(a)
and you should see color :)
Check out this library. This will enable you to use formatted output in the terminal.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With