{"record":{"id":"3fe353affa267dac","repo":"Stirling-Tools/Stirling-PDF","slug":"the-tomlkit-library-is-not-installed-please-ins","errorCode":null,"errorMessage":"The 'tomlkit' library is not installed. Please install it using 'pip install tomlkit'.","messagePattern":"The 'tomlkit' library is not installed\\. Please install it using 'pip install tomlkit'\\.","errorType":"exception","errorClass":"ImportError","httpStatus":null,"severity":"error","filePath":"scripts/counter_translation_v3.py","lineNumber":59,"sourceCode":"Arguments:\n    -l, --lang <locale or file> Specific locale to check (e.g. 'de-DE'),\n                                a directory, or a full path to translation.toml.\n    --show-percentage           Print only the percentage (no formatting, ideal for CI/CD).\n    --show-missing-keys         Show the list of missing keys when checking a single language file.\n\"\"\"\n\nimport argparse\nimport glob\nimport os\nimport re\nimport sys\nfrom collections.abc import Iterable, Mapping\n\n# Ensure tomlkit is installed before importing\ntry:\n    import tomlkit\nexcept ImportError:\n    raise ImportError(\"The 'tomlkit' library is not installed. Please install it using 'pip install tomlkit'.\")\n\nsys.stdout.reconfigure(encoding=\"utf-8\", errors=\"replace\")\n\n\ndef convert_to_multiline(data: tomlkit.TOMLDocument) -> tomlkit.TOMLDocument:\n    \"\"\"Converts 'ignore' and 'missing' arrays to multiline arrays and sorts the first-level keys of the TOML document.\n\n    Enhances readability and consistency in the TOML file by ensuring arrays contain unique and sorted entries.\n\n    Args:\n        data (tomlkit.TOMLDocument): The original TOML document containing the data.\n\n    Returns:\n        tomlkit.TOMLDocument: A new TOML document with sorted keys and properly formatted arrays.\n    \"\"\"\n    sorted_data = tomlkit.document()\n    for key in sorted(data.keys()):\n        value = data[key]","sourceCodeStart":41,"sourceCodeEnd":77,"githubUrl":"https://github.com/Stirling-Tools/Stirling-PDF/blob/9ef20dcab80b85041912f045e17a6aea1d08f969/scripts/counter_translation_v3.py#L41-L77","documentation":"ImportError raised at module load time because the tomlkit third-party library is not installed. The script imports tomlkit to read/write TOML translation files; without the dependency it cannot run.","triggerScenarios":"Running scripts/counter_translation_v3.py in an environment where tomlkit is not installed (no pip install, not in the active virtualenv).","commonSituations":"Fresh checkout without installing script dependencies. Wrong/activating a different virtualenv. Running in CI without the scripts requirements installed.","solutions":["Install the dependency: pip install tomlkit.","Install all script deps if a requirements file exists: pip install -r scripts/requirements.txt.","Pin tomlkit in the project's dependency manifest so it is installed alongside dev tools."],"exampleFix":"# before: ImportError on import\n# after\npip install tomlkit\n# then re-run: python scripts/counter_translation_v3.py ...","handlingStrategy":"validation","validationCode":"# Pre-flight check before running the script\npython -c \"import tomlkit\" 2>/dev/null || pip install tomlkit","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Install script dependencies in the active virtualenv before running.","Pin tomlkit in a requirements file and install via pip install -r.","Use a dedicated virtualenv for project scripts."],"tags":["python","dependencies","scripts","environment"],"backgroundTag":null,"analyzedSha":"9ef20dcab80b85041912f045e17a6aea1d08f969","analyzedAt":"2026-08-13T22:11:39.827Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}