{"id":9748,"library":"flake8-html","title":"flake8-html","description":"flake8-html is a plugin for the flake8 linter that generates an HTML report of code violations, providing a visual and navigable overview of issues. The current version is 0.4.3. It has an infrequent release cadence, primarily updating to maintain compatibility with new versions of flake8.","status":"active","version":"0.4.3","language":"en","source_language":"en","source_url":"https://github.com/lordmauve/flake8-html","tags":["flake8","linting","code quality","html report","development tool","python"],"install":[{"cmd":"pip install flake8-html","lang":"bash","label":"Install plugin"},{"cmd":"pip install flake8 flake8-html","lang":"bash","label":"Install flake8 and plugin"}],"dependencies":[{"reason":"flake8-html is a plugin for flake8 and requires flake8 to be installed and available in the same Python environment to function.","package":"flake8","optional":false}],"imports":[],"quickstart":{"code":"import subprocess\nimport os\n\n# Create a dummy Python file with a flake8 violation\ncode_to_lint = \"\"\"\nimport os\n\ndef my_func( arg1, arg2 ):\n    print( os.path.join(arg1, arg2) )\n\"\"\"\n\nwith open(\"test_code.py\", \"w\") as f:\n    f.write(code_to_lint)\n\n# Ensure the report directory exists\nreport_dir = \"./flake8_html_report\"\nos.makedirs(report_dir, exist_ok=True)\n\n# Run flake8 with the html format\nprint(f\"Running: flake8 --format=html --htmldir={report_dir} .\")\ntry:\n    result = subprocess.run(\n        [\"flake8\", \"--format=html\", f\"--htmldir={report_dir}\", \".\"],\n        capture_output=True,\n        text=True,\n        check=True\n    )\n    print(\"Flake8 HTML report generated successfully.\")\n    print(f\"Report saved to: {os.path.abspath(report_dir)}/report.html\")\nexcept subprocess.CalledProcessError as e:\n    print(f\"Error running flake8: {e}\\n{e.stderr}\")\nexcept FileNotFoundError:\n    print(\"Error: 'flake8' command not found. Please ensure flake8 is installed.\")\nfinally:\n    # Clean up dummy file\n    if os.path.exists(\"test_code.py\"):\n        os.remove(\"test_code.py\")\n    # Optionally, remove the report directory for a clean run next time\n    # import shutil\n    # if os.path.exists(report_dir):\n    #     shutil.rmtree(report_dir)\n","lang":"python","description":"This quickstart demonstrates how to use `flake8-html` via the `flake8` command-line interface. It creates a temporary Python file with a linter violation, runs `flake8` to generate an HTML report, and then cleans up. The `--format=html` and `--htmldir` arguments are essential for generating the report."},"warnings":[{"fix":"Upgrade `flake8-html` to version 0.4.3 or newer: `pip install --upgrade flake8-html`.","message":"Older versions of `flake8-html` (prior to 0.4.3) are incompatible with `flake8` versions 5.0.0 and above.","severity":"breaking","affected_versions":"<0.4.3"},{"fix":"Ensure both `flake8` and `flake8-html` are installed using the same `pip` command or within the same active virtual environment: `pip install flake8 flake8-html`.","message":"For `flake8-html` to be discovered and used by `flake8`, it must be installed in the exact same Python environment (e.g., virtual environment) as `flake8` itself.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Always include `--htmldir=<path/to/directory>` in your `flake8` command to specify where the `report.html` file should be saved.","message":"Failing to specify the `--htmldir` argument will prevent the HTML report from being saved to a file, potentially causing the output to be printed to the console in an unreadable format or not generated at all.","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":"Install `flake8-html` in the same Python environment as `flake8`: `pip install flake8-html`.","cause":"The `flake8-html` plugin is not installed, or `flake8` cannot find it in the current environment.","error":"Error: unrecognized arguments: --format=html"},{"fix":"Ensure you are using `--htmldir=<path/to/report>` to specify the output directory for the HTML report.","cause":"The `--htmldir` argument was either omitted or specified incorrectly, preventing `flake8-html` from saving the report to disk.","error":"No 'report.html' file was generated in the expected directory."},{"fix":"Upgrade `flake8-html` to the latest version to ensure compatibility: `pip install --upgrade flake8-html`.","cause":"This often occurs when `flake8-html < 0.4.3` is used with `flake8 >= 5.0.0` due to compatibility issues.","error":"The generated HTML report is empty or appears incomplete despite having linter violations."}]}