{"id":20914,"library":"aliyun-python-sdk-alimt","title":"Alibaba Cloud Machine Translation SDK for Python","description":"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.","status":"active","version":"3.2.0","language":"python","source_language":"en","source_url":"https://github.com/aliyun/aliyun-openapi-python-sdk/tree/master/alimt","tags":["aliyun","machine-translation","cloud-sdk","alimt"],"install":[{"cmd":"pip install aliyun-python-sdk-alimt","lang":"bash","label":"PyPI install"}],"dependencies":[{"reason":"All Aliyun SDKs require the core library for authentication and client setup.","package":"aliyun-python-sdk-core","optional":false}],"imports":[{"note":"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'.","wrong":"from aliyun_sdk_alimt import Alimt\nimport alimt","symbol":"Alimt","correct":"from aliyunsdkalimt.request.v20181012 import TranslateGeneralRequest\nfrom aliyunsdkcore.client import AcsClient"}],"quickstart":{"code":"import os\nfrom aliyunsdkcore.client import AcsClient\nfrom aliyunsdkalimt.request.v20181012 import TranslateGeneralRequest\n\nclient = AcsClient(\n    os.environ.get('ALIBABA_CLOUD_ACCESS_KEY_ID', ''),\n    os.environ.get('ALIBABA_CLOUD_ACCESS_KEY_SECRET', ''),\n    'cn-hangzhou'\n)\nrequest = TranslateGeneralRequest()\nrequest.set_FormatType('text')\nrequest.set_SourceLanguage('en')\nrequest.set_TargetLanguage('zh')\nrequest.set_SourceText('Hello')\nresponse = client.do_action_with_exception(request)\nprint(response.decode())\n","lang":"python","description":"Quick start: create an AcsClient with credentials from environment variables, then translate text."},"warnings":[{"fix":"Use from aliyunsdkalimt.request.v20181012 import * and install aliyun-python-sdk-core-v3.","message":"In 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'.","severity":"breaking","affected_versions":">=3.0.0"},{"fix":"pip install aliyun-python-sdk-core","message":"The 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.","severity":"gotcha","affected_versions":"all"},{"fix":"Use request.FormatType = 'text' instead of request.set_FormatType('text').","message":"Attribute 'set_*' methods (like set_FormatType) are being deprecated in favor of direct properties in future versions. Currently both work.","severity":"deprecated","affected_versions":">=3.1.0"},{"fix":"Pass the correct region to AcsClient (e.g., 'ap-southeast-1').","message":"The 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.","severity":"gotcha","affected_versions":"all"}],"env_vars":null,"last_verified":"2026-04-27T00:00:00.000Z","next_check":"2026-07-26T00:00:00.000Z","problems":[{"fix":"pip install aliyun-python-sdk-core","cause":"The required core library is missing.","error":"ModuleNotFoundError: No module named 'aliyunsdkcore'"},{"fix":"Ensure ALIBABA_CLOUD_ACCESS_KEY_ID and ALIBABA_CLOUD_ACCESS_KEY_SECRET are set correctly.","cause":"The provided AccessKey ID or Secret is incorrect or the environment variables are not set.","error":"aliyunsdkcore.acs_exceptions.error_code: InvalidAccessKeyId.NotFound"},{"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.","cause":"Passing a string to SourceText when using SDK v3.0 incorrectly. The set_SourceText method expects a string correctly.","error":"TypeError: unsupported operand type(s) for /: 'str' and 'str'"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}