{"id":9463,"library":"ansicon","title":"ANSICON Python Wrapper","description":"The `ansicon` Python library provides a wrapper to load Jason Hood's ANSICON utility, enabling ANSI escape sequences for colored text in the Windows command prompt. It is currently at version 1.89.0, with releases typically mirroring new versions of the underlying ANSICON C utility.","status":"active","version":"1.89.0","language":"en","source_language":"en","source_url":"https://github.com/Rockhopper-Technologies/ansicon","tags":["windows","cli","colors","terminal","ansi"],"install":[{"cmd":"pip install ansicon","lang":"bash","label":"Install `ansicon`"}],"dependencies":[],"imports":[{"note":"You can also import `ansicon` and call `ansicon.load()`.","symbol":"load","correct":"from ansicon import load"}],"quickstart":{"code":"import ansicon\nimport os\n\n# ansicon.load() attempts to find and load ANSICON.exe.\n# It returns True on success and False on failure.\n# For a real application, always check the return value.\nif ansicon.load():\n    print(\"ANSICON loaded successfully. Colors should work in your Windows terminal.\")\n    # Example ANSI escape sequences\n    print('\\033[91mThis is red text\\033[0m')\n    print('\\033[92mThis is green text\\033[0m')\n    print('\\033[94mThis is blue text\\033[0m')\n    print('\\033[1mThis is bold text\\033[0m')\nelse:\n    print(\"Failed to load ANSICON. Colors might not work.\")\n    if os.name == 'nt':\n        print(\"On Windows, ensure ANSICON.exe is in your PATH or script's directory.\")\n    else:\n        print(\"Not on Windows; ANSICON is not applicable. Modern terminals usually support ANSI natively.\")","lang":"python","description":"This quickstart demonstrates how to load ANSICON and print colored text using ANSI escape sequences. It includes a check for successful loading, which is crucial for this library."},"warnings":[{"fix":"Download `ANSICON.exe` from its official source (e.g., adoxa.xyz/ansicon), extract it, and place `ANSICON.exe` in a directory listed in your system's PATH environment variable or in your script's execution directory.","message":"`ANSICON.exe` is required and must be manually acquired and placed in a directory accessible via PATH or the current working directory for the Python wrapper to function.","severity":"gotcha","affected_versions":"All versions"},{"fix":"On non-Windows systems, ANSI escape sequences usually work natively in modern terminals without `ansicon`. If you need cross-platform colored output, consider libraries like `colorama` or `rich`.","message":"The `ansicon` library is primarily designed for Windows operating systems to enable ANSI escape sequences in the native command prompt.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Always check the return value of `ansicon.load()` and provide appropriate fallback or error messages if it returns `False`, as shown in the quickstart example.","message":"`ansicon.load()` returns `True` on success and `False` on failure to load the underlying `ANSICON.exe` utility. Failing to check this return value can lead to silent failures where colors do not appear.","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"last_verified":"2026-04-17T00:00:00.000Z","next_check":"2026-07-16T00:00:00.000Z","problems":[{"fix":"Run `pip install ansicon` to install the library.","cause":"The `ansicon` Python package has not been installed in your current environment.","error":"ModuleNotFoundError: No module named 'ansicon'"},{"fix":"Ensure `ANSICON.exe` is downloaded from adoxa.xyz/ansicon, extracted, and placed in a directory listed in your system's PATH environment variable or in the same directory as your Python script. Verify that `ansicon.load()` returns `True`.","cause":"`ANSICON.exe` was not found or failed to load. The Python wrapper only loads the executable; it doesn't install it.","error":"Colors are not showing in my Windows terminal after calling `ansicon.load()`."}]}