{"id":28346,"library":"tencentcloud-sdk-python-nlp","title":"Tencent Cloud Nlp SDK for Python","description":"Official Tencent Cloud SDK for Natural Language Processing (NLP) service. Provides Python client classes for text classification, sentiment analysis, keyword extraction, and more. Current version 3.1.80, released monthly.","status":"active","version":"3.1.80","language":"python","source_language":"en","source_url":"https://github.com/TencentCloud/tencentcloud-sdk-python","tags":["tencentcloud","nlp","sdk","api","natural-language-processing","chinese"],"install":[{"cmd":"pip install tencentcloud-sdk-python-nlp","lang":"bash","label":"Install via pip"}],"dependencies":[{"reason":"Common base SDK required for client initialization and authentication","package":"tencentcloud-sdk-python-common","optional":false}],"imports":[{"note":"Import directly from module, not class","wrong":"from tencentcloud.nlp.v20190408.nlp_client import NlpClient","symbol":"NlpClient","correct":"from tencentcloud.nlp.v20190408 import nlp_client"},{"note":"Wrong path; version is required","wrong":"import tencentcloud.nlp.models","symbol":"models","correct":"from tencentcloud.nlp.v20190408 import models"}],"quickstart":{"code":"from tencentcloud.common import credential\nfrom tencentcloud.common.exception.tencent_cloud_sdk_exception import TencentCloudSDKException\nfrom tencentcloud.nlp.v20190408 import nlp_client, models\n\ntry:\n    cred = credential.Credential(\n        secret_id=os.environ.get('TENCENTCLOUD_SECRET_ID'),\n        secret_key=os.environ.get('TENCENTCLOUD_SECRET_KEY')\n    )\n    client = nlp_client.NlpClient(cred, \"ap-guangzhou\")\n    req = models.SentimentAnalysisRequest()\n    req.Text = \"今天天气真好\"\n    resp = client.SentimentAnalysis(req)\n    print(resp.to_json_string())\nexcept TencentCloudSDKException as e:\n    print(e)","lang":"python","description":"Initialize client and perform sentiment analysis"},"warnings":[{"fix":"pip install tencentcloud-sdk-python-common tencentcloud-sdk-python-nlp","message":"The SDK is split into per-service packages. You must install both tencentcloud-sdk-python-common and the specific package (e.g., tencentcloud-sdk-python-nlp). Installing only the NLP package does not pull in common automatically.","severity":"gotcha","affected_versions":"all"},{"fix":"Use from tencentcloud.nlp.v20190408 import models","message":"In v3, the model classes and client classes have been moved under versioned paths (v20190408). Old v2-style imports (e.g., from tencentcloud.nlp.models import SentimentAnalysisRequest) no longer work.","severity":"breaking","affected_versions":"3.x"},{"fix":"Always check the official API documentation for required fields and set them before calling the method.","message":"Many API request objects require explicitly setting all fields. Forgetting to set required fields (like Text in SentimentAnalysisRequest) will cause a MissingParameter error.","severity":"gotcha","affected_versions":"all"}],"env_vars":null,"last_verified":"2026-05-09T00:00:00.000Z","next_check":"2026-08-07T00:00:00.000Z","problems":[{"fix":"pip install tencentcloud-sdk-python-common","cause":"Common package not installed","error":"ModuleNotFoundError: No module named 'tencentcloud'"},{"fix":"from tencentcloud.nlp.v20190408 import models","cause":"Wrong import path; models are under versioned subpackage","error":"ImportError: cannot import name 'SentimentAnalysisRequest' from 'tencentcloud.nlp.models'"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}