{"id":4169,"library":"pep8","title":"PEP 8 (legacy package)","description":"The `pep8` package, version 1.7.1, is a Python style guide checker that verifies code against some of the conventions in PEP 8. This package has been renamed to `pycodestyle` to reduce confusion between the tool and the actual PEP 8 style guide document. While still installable, users are strongly encouraged to use `pycodestyle` instead. The package is in maintenance mode under its old name, with active development continuing as `pycodestyle`.","status":"maintenance","version":"1.7.1","language":"en","source_language":"en","source_url":"https://github.com/pycqa/pep8","tags":["code quality","style guide","linter","pep8","pycodestyle"],"install":[{"cmd":"pip install pep8","lang":"bash","label":"Install pep8 (legacy)"},{"cmd":"pip install pycodestyle","lang":"bash","label":"Install pycodestyle (recommended)"}],"dependencies":[],"imports":[{"note":"The `pep8.Checker` class exists for direct programmatic use with the legacy `pep8` package. For new projects or updated code, use `from pycodestyle import Checker` instead.","wrong":"from pycodestyle import Checker","symbol":"Checker","correct":"from pep8 import Checker"}],"quickstart":{"code":"import os\n\n# Create a dummy Python file to check\nwith open('example.py', 'w') as f:\n    f.write('def my_function(a,b):\\n    return a+ b\\n')\n\n# Command-line usage (typical)\n# import subprocess\n# subprocess.run(['pep8', 'example.py'])\n\n# Programmatic usage of the legacy pep8 package\nfrom pep8 import Checker\n\n# You can pass a filename or a file-like object\nchecker = Checker('example.py')\nerrors = checker.check_all()\n\nprint(f\"Found {errors} style errors.\")\nif errors > 0:\n    print(\"Note: The pep8 package prints errors directly to stdout during check_all().\")\n\n# Cleanup (optional)\nos.remove('example.py')","lang":"python","description":"The `pep8` package is primarily used via its command-line interface. For programmatic checks, you can import `Checker` and instantiate it with a file path. The `check_all()` method runs checks and prints errors directly to stdout, returning the total count of errors found. For modern usage, consider the `pycodestyle` package."},"warnings":[{"fix":"Migrate to `pycodestyle`. Uninstall `pep8` and install `pycodestyle`: `pip uninstall pep8 && pip install pycodestyle`. Update import statements from `pep8` to `pycodestyle` (e.g., `from pep8 import Checker` becomes `from pycodestyle import Checker`).","message":"The `pep8` package has been renamed to `pycodestyle`. While `pep8` (version 1.7.1) is still available on PyPI, it is no longer actively maintained under this name. New features and bug fixes are exclusively released in `pycodestyle`.","severity":"breaking","affected_versions":"1.7.0 and older"},{"fix":"For command-line usage, redirect output to a file if you need to capture it. For programmatic integration, consider using the `pycodestyle` library, which offers more options for handling reported errors, or capturing `stdout` if sticking with `pep8`.","message":"The `pep8` command-line tool and its programmatic interface directly print style errors to standard output. This can make it challenging to capture and process errors programmatically without redirecting output or using `pycodestyle`'s more flexible API.","severity":"gotcha","affected_versions":"All versions of pep8 (1.0 - 1.7.1)"},{"fix":"Configure your editor to use 4 spaces for indentation and ensure 'tabs to spaces' conversion is enabled. Use tools like `autopep8` or `black` for automatic formatting.","message":"Mixing tabs and spaces for indentation is a common PEP 8 violation that often leads to hard-to-debug `IndentationError` in Python 3. PEP 8 strongly recommends using 4 spaces per indentation level.","severity":"gotcha","affected_versions":"All Python versions, checked by pep8 1.0 - 1.7.1"}],"env_vars":null,"last_verified":"2026-04-11T00:00:00.000Z","next_check":"2026-07-10T00:00:00.000Z"}