Registry / ai-ml / aliyun-python-sdk-alimt

aliyun-python-sdk-alimt

JSON →
library3.2.0pypypi✓ verified 85d ago

The Alibaba Cloud Machine Translation (alimt) SDK for Python, part of the Aliyun Python SDK family. Version 3.2.0 provides APIs for text translation, image translation, and document translation. Release cadence is irregular, tied to API updates.

pip install aliyun-python-sdk-alimt
INSTALL
IMPORT
SIG · ALIYUN-PYTHON-SDK-
A
aliyun-python-sdk-alimt
ai-mlpythonv3.2.0
Install
3.9s avg
Import
298ms
Disk
37MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v3.2.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.308s · 39.4MB
glibc
py 3.103.95 runs
installs and imports cleanly · install 3.9s · import 0.288s · 40MB
37MB installed
● package 37MB
Code
Verified usage

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

Alimt
from aliyunsdkalimt.request.v20181012 import TranslateGeneralRequest from aliyunsdkcore.client import AcsClient
from aliyun_sdk_alimt import Alimt import alimt
The old path was changed in v2. The correct import uses subpackages based on API version. The top-level package 'aliyunsdkalimt' must be used, not 'aliyun_sdk_alimt'.

Quick start: create an AcsClient with credentials from environment variables, then translate text.

import os from aliyunsdkcore.client import AcsClient from aliyunsdkalimt.request.v20181012 import TranslateGeneralRequest client = AcsClient( os.environ.get('ALIBABA_CLOUD_ACCESS_KEY_ID', ''), os.environ.get('ALIBABA_CLOUD_ACCESS_KEY_SECRET', ''), 'cn-hangzhou' ) request = TranslateGeneralRequest() request.set_FormatType('text') request.set_SourceLanguage('en') request.set_TargetLanguage('zh') request.set_SourceText('Hello') response = client.do_action_with_exception(request) print(response.decode())
Debug
Known issues
breakingIn v3, the API version suffix changed from v20181012 to v20181012 (no change). However, the package structure was reorganized. If you were using v1 (aliyun-python-sdk-alimt<2.0), you must update imports from 'alimt' to 'aliyunsdkalimt'.
fix
Use from aliyunsdkalimt.request.v20181012 import * and install aliyun-python-sdk-core-v3.
affects: >=3.0.0
gotchaThe core library aliyun-python-sdk-core must be installed separately; it does not come as a dependency automatically. Use pip install aliyun-python-sdk-core.
fix
pip install aliyun-python-sdk-core
affects: all
deprecatedAttribute 'set_*' methods (like set_FormatType) are being deprecated in favor of direct properties in future versions. Currently both work.
fix
Use request.FormatType = 'text' instead of request.set_FormatType('text').
affects: >=3.1.0
gotchaThe API endpoint defaults to 'mt.cn-hangzhou.aliyuncs.com'. If your Region is not cn-hangzhou, you must set the endpoint region explicitly via client.set_region_id('your-region') or AcsClient's third argument.
fix
Pass the correct region to AcsClient (e.g., 'ap-southeast-1').
affects: all
Errors
Common errors & fixes
ModuleNotFoundError: No module named 'aliyunsdkcore'
The required core library is missing.
fix
pip install aliyun-python-sdk-core
aliyunsdkcore.acs_exceptions.error_code: InvalidAccessKeyId.NotFound
The provided AccessKey ID or Secret is incorrect or the environment variables are not set.
fix
Ensure ALIBABA_CLOUD_ACCESS_KEY_ID and ALIBABA_CLOUD_ACCESS_KEY_SECRET are set correctly.
TypeError: unsupported operand type(s) for /: 'str' and 'str'
Passing a string to SourceText when using SDK v3.0 incorrectly. The set_SourceText method expects a string correctly.
fix
This error typically occurs if you use the request incorrectly. Ensure you are calling set_SourceText with a plain string, not a dict or list.
Upgrade
Version history
3.2.0latest on PyPI · released Apr 11, 2023
Audit
Dependencies
aliyun-python-sdk-corerequiredAll Aliyun SDKs require the core library for authentication and client setup.
Agent activity
67 hits · last 30 days
node
56
OpenAI (training)
2
Resources
aliyun-python-sdk-alimt — pip install aliyun-python-sdk-alimt · libregistry