Registry / http-networking / gpytranslate

gpytranslate

JSON →
library2.1.0pypypi✓ verified 84d ago

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.

pip install gpytranslate
INSTALL
IMPORT
SIG · GPYTRANSLATE
G
gpytranslate
http-networkingpythonv2.1.0
Install
2.2s avg
Import
219ms
Disk
20MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v2.0.0 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.95 runs
installs and imports cleanly · install 0.0s · import 0.228s · 22.2MB
glibc
py 3.103.95 runs
installs and imports cleanly · install 2.2s · import 0.210s · 23MB
20MB installed
● package 20MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

Translator
from gpytranslate import Translator
from gpytranslate.translator import Translator
Translator is re-exported at the package level.
SyncTranslator
from gpytranslate import SyncTranslator
from gpytranslate.sync import SyncTranslator
SyncTranslator is re-exported at the package level.

Basic async translation example using Translator as an async context manager.

import asyncio from gpytranslate import Translator async def main(): async with Translator() as t: result = await t.translate("Hello world", sourcelang="en", targetlang="es") print(result.text) # Output: Hola mundo asyncio.run(main())
Debug
Known issues
breakingVersion 2.0.0 dropped support for Python <3.12. Install with pip will fail on older interpreters.
fix
Upgrade to Python 3.12+ or pin to gpytranslate==1.5.1 if you need older Python.
affects: <4.0,>=3.12
breakingThe 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.
fix
Wrap usage in `async with Translator() as t:` or explicitly call `await t.close()` when done.
affects: >=2.0.0
gotchaGoogle Translate may rate-limit requests. The library raises TranslateError in such cases, not JSON errors. Catching generic Exception may hide the cause.
fix
Catch `gpytranslate.TranslateError` specifically and implement retry logic with exponential backoff.
affects: >=1.4.0
gotchaThe sync translator (SyncTranslator) is not a context manager; you must create and use it directly. Attempting `async with SyncTranslator()` will raise AttributeError.
fix
Use: `t = SyncTranslator(); result = t.translate(...)`
affects: >=1.1.0
deprecatedThe `__version__` attribute on Translator instances is deprecated; use `gpytranslate.__version__` instead.
fix
Replace `translator.__version__` with `from gpytranslate import __version__`
affects: >=1.1.0
Errors
Common errors & fixes
AttributeError: module 'gpytranslate' has no attribute 'Translator'
The library was not correctly installed or imported due to a broken installation.
fix
Reinstall: `pip install --upgrade gpytranslate`. Verify import in a fresh Python session.
gpytranslate.TranslateError: Too many requests
Google Translate API rate limit exceeded.
fix
Add delays between requests or use a proxy rotation. Reduce request frequency.
RuntimeError: asyncio.run() cannot be called from a running event loop
Trying to use asyncio.run() inside an async context (e.g., Jupyter notebook or another async function).
fix
Use `await` directly in async context or use `asyncio.run()` only from sync entry points.
Upgrade
Version history
2.1.0latest on PyPI · released Dec 22, 2025
Audit
Dependencies
aiohttprequiredAsync HTTP client for API calls
aiofilesoptionalAsync file I/O for TTS audio saving
Agent activity
21 hits · last 30 days
node
18
OpenAI (training)
1
Resources
gpytranslate — pip install gpytranslate · libregistry