简体   繁体   English

如何在 vscode 中为 output 添加颜色

[英]how do I add color to output in vscode

I want to have colored error messages in VScode.我想在 VScode 中显示彩色错误消息。

I tried to install the Output Colorizer extension but it didn't work.我尝试安装Output Colorizer扩展,但没有成功。

I also tried to change the sitecustomize.py file by using the coloredlogs and IPython libraries but it didn't work either way:我还尝试通过使用coloredlogsIPython库来更改sitecustomize.py文件,但这两种方法都不起作用:

when I tried to use coloredlogs I got this error message:当我尝试使用 colourlogs 时,我收到了以下错误消息:

Error in sitecustomize; set PYTHONVERBOSE for traceback:
ModuleNotFoundError: No module named 'coloredlogs'
Traceback (most recent call last):
  File "c:\Users\MyUsername\AppData\Local\Programs\Python\Python39\Lib\site-packages\sitecustomize.py", line 1, in <module>
    import coloredlogs
ModuleNotFoundError: No module named 'coloredlogs'

even though I tried the demo and it worked.即使我尝试了演示并且它有效。

  1. For the extension "Output Colorizer", it is for changing the color of the log file in "OUTPUT": " Syntax highlighting for log files ":对于扩展名“Output Colorizer”,用于更改“OUTPUT”中日志文件的颜色:“ Syntax highlighting for log files ”:

    在此处输入图像描述

  2. For using the module " coloredlogs ", we need to install this module in the currently selected python environment (lower left corner of VS Code).为了使用模块“ coloredlogs ”,我们需要在当前选择的python环境(VS Code的左下角)安装这个模块。

    (install: pip install coloredlogs check: pip show coloredlogs ) (安装: pip install coloredlogs检查: pip show coloredlogs

    在此处输入图像描述

Reference: Python environment in VS Code .参考: VS Code 中的 Python 环境

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM