{"id":8834,"library":"argostranslate","title":"Argos Translate","description":"Argos Translate is an open-source neural machine translation (NMT) library for Python, based on OpenNMT's CTranslate2. It enables offline translation, supporting a wide array of languages through downloadable '.argosmodel' packages. The library can be utilized as a Python API, a command-line tool, or a GUI application. The current version is 1.11.0, with new releases typically published every three months.","status":"active","version":"1.11.0","language":"en","source_language":"en","source_url":"https://github.com/argosopentech/argos-translate","tags":["translation","NMT","NLP","offline","machine learning"],"install":[{"cmd":"pip install argostranslate","lang":"bash","label":"Install core library"}],"dependencies":[{"reason":"Core neural machine translation engine.","package":"ctranslate2","optional":false},{"reason":"Used for tokenization of text.","package":"sentencepiece","optional":false},{"reason":"Used for sentence boundary detection (SBD).","package":"stanza","optional":true}],"imports":[{"note":"While 'from argostranslate import package' might work, the documentation and examples consistently use the fully qualified 'import argostranslate.package' and 'import argostranslate.translate' to avoid name collisions and for clarity.","wrong":"from argostranslate import package","symbol":"package","correct":"import argostranslate.package"},{"note":"See note for 'package' import.","wrong":"from argostranslate import translate","symbol":"translate","correct":"import argostranslate.translate"}],"quickstart":{"code":"import argostranslate.package\nimport argostranslate.translate\n\n# Define source and target languages using ISO 639-1 codes\nfrom_code = \"en\"\nto_code = \"es\"\n\n# Update package index and download/install the desired language model\nprint(\"Updating package index...\")\nargostranslate.package.update_package_index()\n\navailable_packages = argostranslate.package.get_available_packages()\npackage_to_install = next(\n    filter(\n        lambda x: x.from_code == from_code and x.to_code == to_code,\n        available_packages\n    ),\n    None\n)\n\nif package_to_install:\n    print(f\"Downloading and installing {from_code} -> {to_code} package...\")\n    download_path = package_to_install.download()\n    argostranslate.package.install_from_path(download_path)\n    print(\"Package installed.\")\nelse:\n    print(f\"No package found for {from_code} -> {to_code}. Please check available packages or codes.\")\n\n# Perform translation\ninstalled_languages = argostranslate.translate.get_installed_languages()\nfrom_lang = next(filter(lambda x: x.code == from_code, installed_languages), None)\nto_lang = next(filter(lambda x: x.code == to_code, installed_languages), None)\n\nif from_lang and to_lang:\n    print(f\"Translating 'Hello World' from {from_code} to {to_code}...\")\n    translatedText = from_lang.get_translation(to_lang).translate(\"Hello World\")\n    print(f\"Translated text: {translatedText}\")\nelse:\n    print(\"Source or target language not found among installed languages.\")","lang":"python","description":"This quickstart demonstrates how to programmatically download and install a language model, then use it to translate text. The library requires explicit installation of language models (e.g., 'en' to 'es') after the main library itself is installed."},"warnings":[{"fix":"Refer to the official documentation or GitHub release notes for specific API changes. Update deprecated function calls to their newer equivalents (e.g., `get_available_packages()` instead of `load_available_packages()`).","message":"Major breaking changes occurred around versions 1.2 and 1.4, specifically deprecating `load_available_packages` for `get_available_packages` and `load_installed_languages` for `get_installed_languages`. Other changes affected `translate.apply_packaged_translation`, `ITranslate.split_into_paragraphs`, and `package.Package.remove`.","severity":"breaking","affected_versions":"1.2, 1.4"},{"fix":"Instead of `argostranslate.translate.translate(text, from_code, to_code)` in a loop, load the `ITranslation` object once: `installed_languages = argostranslate.translate.get_installed_languages(); from_lang = ...; to_lang = ...; translation_obj = from_lang.get_translation(to_lang);` Then, call `translated_text = translation_obj.translate(text)` repeatedly.","message":"Repeated calls to `argostranslate.translate.translate()` within a loop can be inefficient due to models potentially being reloaded. It's more performant to load the translation object once and reuse it.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Ensure you are using the latest `argostranslate` version and `pip`. If issues persist, consider using a slightly older Python version (e.g., 3.11) or checking the `ctranslate2` and `sentencepiece` project pages for Python 3.12 compatibility updates.","message":"Installation issues on Python 3.12 have been reported, primarily due to underlying dependencies like `ctranslate2` or `sentencepiece` not having readily available wheels or requiring specific build environments for Python 3.12 at the time of the issue.","severity":"gotcha","affected_versions":">=3.12 (specifically early 3.12 releases)"}],"env_vars":null,"last_verified":"2026-04-16T00:00:00.000Z","next_check":"2026-07-15T00:00:00.000Z","problems":[{"fix":"You must explicitly download and install language models. Use `argostranslate.package.update_package_index()` to get available packages, then filter and install the desired one using `argostranslate.package.install_from_path(package_to_install.download())`. Alternatively, use the `argospm` command-line tool: `argospm install translate-en_es`.","cause":"The core `argostranslate` library is installed, but the specific language model package (e.g., English to Spanish) has not been downloaded and installed.","error":"Package not found for translating from 'en' to 'es'."},{"fix":"Ensure that the directory where `pip` installs executables (often `~/.local/bin` on Linux/macOS, or `Scripts` subdirectory in your Python installation on Windows) is included in your system's PATH environment variable. Using a Python virtual environment and activating it can help manage this. On Windows, you might need to invoke it via `python -m argostranslate.cli` or specify the full path to the script.","cause":"The `argos-translate` or `argos-translate-gui` executables are not in your system's PATH, or they are not correctly linked/aliased after installation.","error":"'argos-translate' is not recognized as an internal or external command, operable program or batch file."},{"fix":"Ensure you have the necessary build tools for Python packages (e.g., Microsoft C++ Build Tools on Windows). If using a specific Python version (like 3.12), verify compatibility for `ctranslate2` and `sentencepiece`. A clean virtual environment can sometimes resolve conflicts.","cause":"This error can occur during installation or execution, often related to underlying C++ dependencies (like `ctranslate2` needing a specific compiler or runtime, or `sentencepiece` build issues) or missing system-level tools.","error":"FileNotFoundError: [WinError 2] The system cannot find the file specified"}]}