{"id":23808,"library":"gpytranslate","title":"gpytranslate","description":"An async-first Python library for translating text using the Google Translate API. Currently at version 2.1.0, it requires Python >=3.12 and uses aiohttp for async HTTP requests. The library provides both async (Translator) and sync (SyncTranslator) interfaces, along with language detection and text-to-speech (TTS) support. Releases are sporadic, with the last major update in 2025.","status":"active","version":"2.1.0","language":"python","source_language":"en","source_url":"https://github.com/DavideGalilei/gpytranslate","tags":["translation","google-translate","async","text-to-speech"],"install":[{"cmd":"pip install gpytranslate","lang":"bash","label":"Install from PyPI"}],"dependencies":[{"reason":"Async HTTP client for API calls","package":"aiohttp","optional":false},{"reason":"Async file I/O for TTS audio saving","package":"aiofiles","optional":true}],"imports":[{"note":"Translator is re-exported at the package level.","wrong":"from gpytranslate.translator import Translator","symbol":"Translator","correct":"from gpytranslate import Translator"},{"note":"SyncTranslator is re-exported at the package level.","wrong":"from gpytranslate.sync import SyncTranslator","symbol":"SyncTranslator","correct":"from gpytranslate import SyncTranslator"}],"quickstart":{"code":"import asyncio\nfrom gpytranslate import Translator\n\nasync def main():\n    async with Translator() as t:\n        result = await t.translate(\"Hello world\", sourcelang=\"en\", targetlang=\"es\")\n        print(result.text)  # Output: Hola mundo\n\nasyncio.run(main())","lang":"python","description":"Basic async translation example using Translator as an async context manager."},"warnings":[{"fix":"Upgrade to Python 3.12+ or pin to gpytranslate==1.5.1 if you need older Python.","message":"Version 2.0.0 dropped support for Python <3.12. Install with pip will fail on older interpreters.","severity":"breaking","affected_versions":"<4.0,>=3.12"},{"fix":"Wrap usage in `async with Translator() as t:` or explicitly call `await t.close()` when done.","message":"The Translator class now uses an async context manager (async with) for proper resource cleanup. Using it without a context manager may leak connections in older code.","severity":"breaking","affected_versions":">=2.0.0"},{"fix":"Catch `gpytranslate.TranslateError` specifically and implement retry logic with exponential backoff.","message":"Google Translate may rate-limit requests. The library raises TranslateError in such cases, not JSON errors. Catching generic Exception may hide the cause.","severity":"gotcha","affected_versions":">=1.4.0"},{"fix":"Use: `t = SyncTranslator(); result = t.translate(...)`","message":"The sync translator (SyncTranslator) is not a context manager; you must create and use it directly. Attempting `async with SyncTranslator()` will raise AttributeError.","severity":"gotcha","affected_versions":">=1.1.0"},{"fix":"Replace `translator.__version__` with `from gpytranslate import __version__`","message":"The `__version__` attribute on Translator instances is deprecated; use `gpytranslate.__version__` instead.","severity":"deprecated","affected_versions":">=1.1.0"}],"env_vars":null,"search_vec":"'2.1.0':19 '2025':61 '3.12':23 'aiohttp':26 'along':41 'api':15 'async':4,28,35,66 'async-first':3 'current':16 'detect':44 'first':5 'googl':13,64 'google-transl':63 'gpytransl':1 'http':29 'interfac':40 'languag':43 'last':57 'librari':7,32 'major':58 'provid':33 'python':6,22 'releas':52 'request':30 'requir':21 'speech':49,70 'sporad':54 'support':51 'sync':38 'synctransl':39 'text':10,47,68 'text-to-speech':46,67 'translat':9,14,36,62,65 'tts':50 'updat':59 'use':11,25 'version':18","created_at":"2026-05-01T08:09:44.219855+00:00","updated_at":"2026-05-01T08:09:44.219855+00:00","problems":[{"fix":"Reinstall: `pip install --upgrade gpytranslate`. Verify import in a fresh Python session.","cause":"The library was not correctly installed or imported due to a broken installation.","error":"AttributeError: module 'gpytranslate' has no attribute 'Translator'"},{"fix":"Add delays between requests or use a proxy rotation. Reduce request frequency.","cause":"Google Translate API rate limit exceeded.","error":"gpytranslate.TranslateError: Too many requests"},{"fix":"Use `await` directly in async context or use `asyncio.run()` only from sync entry points.","cause":"Trying to use asyncio.run() inside an async context (e.g., Jupyter notebook or another async function).","error":"RuntimeError: asyncio.run() cannot be called from a running event loop"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":"2.1.0","cli_name":"","cli_version":null,"type":"library","homepage":null,"github":"https://github.com/DavideGalilei/gpytranslate","docs":null,"changelog":null,"pypi":"https://pypi.org/project/gpytranslate/","npm":null,"openapi_spec":null,"status_page":null,"smithery":null,"categories":["http-networking","aws","gcp"],"base_url":null,"auth_type":null,"provenance":{"verified_status":"passing","verified_at":"2026-06-29","last_verified":"2026-06-29","next_check":"2026-07-29","install_tag":null}}