Registry / testing / colorama

colorama

JSON →
library0.4.6pypypi✓ verified 30d ago

Colorama is a Python library that simplifies printing colored text and styles to the terminal, ensuring cross-platform compatibility, especially on Windows. The current version is 0.4.6, released on October 25, 2022. The library has a stable release cadence, with updates addressing compatibility and minor feature enhancements.

pip install colorama
INSTALL
IMPORT
SIG · COLORAMA
C
colorama
testingpythonv0.4.6
Install
1.7s avg
Import
18ms
Disk
16MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.9–3.13
musl
3.9–3.13
Install & Compatibility
Where this runs
tested against v0.4.6 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.10–3.95 runs
installs and imports cleanly · install 0.0s · import 0.012s · 18MB
glibc
py 3.10–3.95 runs
installs and imports cleanly · install 1.7s · import 0.024s · 18MB
16MB installed
● package 16MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

init
✓ from colorama import init
Ensure to import 'init' for initializing Colorama.
Fore
✓ from colorama import Fore
Import 'Fore' to access foreground color constants.
Back
✓ from colorama import Back
Import 'Back' to access background color constants.
Style
✓ from colorama import Style
Import 'Style' to access text style constants.

Initialize Colorama with auto-reset and print colored and styled text.

from colorama import init, Fore, Back, Style init(autoreset=True) print(Fore.RED + 'This is red text') print(Back.GREEN + 'This has a green background') print(Style.BRIGHT + 'This is bright text') print('Back to normal text')
Debug
Known issues
gotchaOn Windows, failing to call 'init()' may result in ANSI escape sequences being displayed as raw text instead of colored output.
fix
Always call 'init()' at the start of your program to initialize Colorama.
affects: All versions
gotchaUsing 'init(autoreset=True)' resets styles after each print statement, which may not be desired in all cases.
fix
Use 'init(autoreset=False)' if you prefer to manually reset styles.
affects: All versions
gotchaColorama's 'Style.DIM' may not be supported on all terminals, leading to inconsistent text appearance.
fix
Test your application on target terminals to ensure consistent styling.
affects: All versions
gotchaCombining Colorama with other ANSI-based libraries without proper initialization may lead to unexpected behavior.
fix
Ensure Colorama is initialized before using it with other ANSI-based libraries.
affects: All versions
Errors
Common errors & fixes
ModuleNotFoundError: No module named 'colorama'
The colorama library is not installed in the Python environment you are currently using, or it was installed for a different Python version than the one executing your script.
fix
Install the colorama package using pip: `pip install colorama` or `pip3 install colorama`. If using an IDE like VS Code, ensure the correct Python interpreter is selected that has colorama installed.
AttributeError: module 'colorama' has no attribute 'init'
This error often occurs when `init` (or `Fore`, `Back`, `Style`) is not correctly imported from the `colorama` module, or there's a shadowing file named `colorama.py` in your project directory.
fix
Ensure you are importing `init` directly, for example: `from colorama import init, Fore, Back, Style`. Alternatively, if you `import colorama`, you must call `colorama.init()`. Also, check that you don't have a local file named `colorama.py` conflicting with the installed package.
Colorama not working / no colors in Windows terminal / PowerShell / VS Code
On Windows, Colorama typically needs to initialize itself to convert ANSI escape codes into native Windows console API calls. If `init()` is not called, or if the terminal environment (like some older PowerShell versions or certain IDE integrated terminals) doesn't fully support ANSI escape sequences by default, colors may not display.
fix
Call `colorama.init()` at the beginning of your script. For persistent issues on Windows, especially older versions or specific terminals, explicitly pass `convert=True` to `init()`: `init(convert=True)`. As of Colorama 0.4.6, `just_fix_windows_console()` can also be used for minimal setup.
ImportError: cannot import name 'Fore' from 'colorama'
This typically happens due to a case sensitivity error, where 'fore' is used instead of 'Fore' (or 'back' instead of 'Back', 'style' instead of 'Style'). Python imports are case-sensitive.
fix
Correct the import statement to use the proper capitalization: `from colorama import Fore, Back, Style`.
Upgrade
Version history
0.4.6latest on PyPI · released Oct 25, 2022
Audit
Dependencies

No dependency data recorded yet.

Agent activity
49 hits · last 30 days
node
40
Meta
1
OpenAI (training)
1
CCBot/2.0 (https://commoncrawl.o
1
Resources
colorama — pip install colorama · libregistry