{"id":8265,"library":"language-tool-python","title":"LanguageTool Python Wrapper","description":"language_tool_python is an actively maintained Python wrapper for LanguageTool, an open-source grammar, style, and spell checker. It facilitates grammar checking by either running a local LanguageTool Java server, utilizing the public LanguageTool API, or connecting to a custom remote LanguageTool server. The library sees regular minor and patch releases, ensuring active development and updates.","status":"active","version":"3.3.0","language":"en","source_language":"en","source_url":"https://github.com/jxmorris12/language_tool_python","tags":["nlp","grammar-checker","spell-checker","languagetool","text-processing"],"install":[{"cmd":"pip install language-tool-python","lang":"bash","label":"Install with pip"}],"dependencies":[{"reason":"Used for making HTTP requests to LanguageTool servers (public or remote).","package":"requests","optional":false},{"reason":"Provides progress bars for operations like downloading LanguageTool JAR files.","package":"tqdm","optional":false},{"reason":"Used for version parsing and comparison.","package":"packaging","optional":false},{"reason":"Used for process management, particularly when running a local LanguageTool Java server.","package":"psutil","optional":false},{"reason":"Used for reading TOML configuration files.","package":"toml","optional":false}],"imports":[{"note":"The primary class for interacting with LanguageTool, supporting local, public, and custom remote servers.","wrong":"import language_tool_python.LanguageTool","symbol":"LanguageTool","correct":"from language_tool_python import LanguageTool"},{"note":"A specialized class for direct interaction with the public LanguageTool API.","wrong":"from language_tool_python import PublicAPI","symbol":"LanguageToolPublicAPI","correct":"from language_tool_python import LanguageToolPublicAPI"}],"quickstart":{"code":"import language_tool_python\n\n# For local server (requires Java JRE installed)\n# Ensure Java Runtime Environment (JRE) is installed and accessible in your PATH\ntry:\n    with language_tool_python.LanguageTool('en-US') as tool:\n        text = \"This are a example of bad grammer.\"\n        matches = tool.check(text)\n        print(\"Original text:\", text)\n        print(\"Detected errors:\", matches)\n        corrected_text = tool.correct(text)\n        print(\"Corrected text:\", corrected_text)\nexcept Exception as e:\n    print(f\"Could not initialize local LanguageTool server: {e}\")\n    print(\"Trying public API...\")\n\n# For public LanguageTool API\n# Note: Public API has rate limits. For heavy usage, consider a local/remote server.\ntry:\n    with language_tool_python.LanguageToolPublicAPI('en-US') as tool:\n        text_public = \"He don't like it.\"\n        matches_public = tool.check(text_public)\n        print(\"\\nOriginal text (Public API):\", text_public)\n        print(\"Detected errors (Public API):\", matches_public)\n        corrected_text_public = tool.correct(text_public)\n        print(\"Corrected text (Public API):\", corrected_text_public)\nexcept Exception as e:\n    print(f\"Could not use public LanguageTool API: {e}\")\n    print(\"Check your internet connection or API rate limits.\")\n","lang":"python","description":"This quickstart demonstrates how to use `language-tool-python` with both a local LanguageTool server (which requires a Java JRE) and the public LanguageTool API. It checks a sample sentence for grammar errors and applies corrections. The `with` statement is recommended for proper resource management."},"warnings":[{"fix":"Install a compatible JRE and ensure `java` is in your system's PATH.","message":"A Java Runtime Environment (JRE) is required on your system to run the local LanguageTool server (the default mode). Specific Java versions are required depending on the LanguageTool version: Java >= 9 for LT < 6.6, and Java >= 17 for LT >= 6.6.","severity":"gotcha","affected_versions":"All versions (for local server mode)"},{"fix":"Only use `proxies` when connecting to a specific `remote_server`. If you intend to use a local server, remove the `proxies` argument.","message":"The `proxies` parameter in the `LanguageTool` constructor is only effective when `remote_server` is also specified. Passing `proxies` without `remote_server` will raise a `ValueError`.","severity":"gotcha","affected_versions":"All versions"},{"fix":"For high-volume usage, configure `language-tool-python` to use a local LanguageTool server (requires Java) or your own remote LanguageTool instance.","message":"Using the public LanguageTool API (`LanguageToolPublicAPI`) is subject to rate limits. For intensive or production use, it is highly recommended to run your own local LanguageTool server or connect to a custom remote server.","severity":"deprecated","affected_versions":"All versions"},{"fix":"Ensure you are using LanguageTool server version 4.0 or newer. The library by default downloads the latest compatible version.","message":"As of April 2020 (starting with version 2.x), `language-tool-python` no longer supports LanguageTool server versions older than 4.0.","severity":"breaking","affected_versions":"< 2.0.0"}],"env_vars":null,"last_verified":"2026-04-16T00:00:00.000Z","next_check":"2026-07-15T00:00:00.000Z","problems":[{"fix":"Install a compatible JRE (Java 17 or newer is recommended for recent LanguageTool versions) and ensure the `java` executable is available in your system's PATH. On Linux/macOS, check `java --version`. On Windows, ensure Java's `bin` directory is in the Path environment variable.","cause":"The Java Runtime Environment (JRE) is either not installed or not correctly configured in your system's PATH, which is required to run the local LanguageTool server.","error":"FileNotFoundError: [Errno 2] No such file or directory: 'java'"},{"fix":"Install the library using `pip install language-tool-python`. If already installed, verify your Python environment by checking `pip list` or `conda list`.","cause":"The `language-tool-python` library is not installed in your current Python environment, or you are running the script in a different environment.","error":"ModuleNotFoundError: No module named 'language_tool_python'"},{"fix":"Remove the `proxies` argument if you intend to use a local LanguageTool server, or add the `remote_server` argument with a valid URL if you intend to use a remote server with proxies.","cause":"You have provided the `proxies` argument to `language_tool_python.LanguageTool` without also specifying the `remote_server` argument. Proxies are only used for remote HTTP connections.","error":"ValueError: proxies works only with remote_server"},{"fix":"Refer to the official documentation or the `Match` object's `__dict__` for available attributes. Common attributes include `ruleId`, `message`, `replacements`, `offset`, `errorLength`, `context`, `category`.","cause":"You are trying to access an attribute on a `Match` object that does not exist or has a different name than expected. This can happen from typos or outdated examples.","error":"AttributeError: 'Match' object has no attribute 'some_invalid_attribute'"}]}