pythonvisual-studiocolorama

Python library Colorama stopped working in Visual Studio


I am writing a project in Python 3.9 using Visual Studio Version 17. This project uses colorama to add color to the terminal text.

Recently, I installed anaconda on my computer as part of an unrelated project. When I returned to my original project in VS and tried to run it, I found that the output window no longer renders the colors; instead it outputs the raw color codes from colorama such as ←[33m. However, when I run my project from the terminal directly, everything renders correctly.

I should note that there are 3 environments currently available for my project: Python 3.9 (which I was using before), Python 3.10, and Anaconda. Only Python 3.9 runs because the other environments do not have other dependencies installed such as scapy. Not sure if it's relevant to my issue, but figured I would mention it.


Solution

  • Found the issue. Forgot to add colorama.init() to the start of my code.