Registry / gcp / tencentcloud-sdk-python-nlp

tencentcloud-sdk-python-nlp

JSON →
library3.1.80pypypi✓ verified 87d ago

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.

pip install tencentcloud-sdk-python-nlp
INSTALL
IMPORT
SIG · TENCENTCLOUD-SDK-P
T
tencentcloud-sdk-python-nlp
gcppythonv3.1.80
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

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

NlpClient
✓ from tencentcloud.nlp.v20190408 import nlp_client
✗ from tencentcloud.nlp.v20190408.nlp_client import NlpClient
Import directly from module, not class
models
✓ from tencentcloud.nlp.v20190408 import models
✗ import tencentcloud.nlp.models
Wrong path; version is required

Initialize client and perform sentiment analysis

from tencentcloud.common import credential from tencentcloud.common.exception.tencent_cloud_sdk_exception import TencentCloudSDKException from tencentcloud.nlp.v20190408 import nlp_client, models try: cred = credential.Credential( secret_id=os.environ.get('TENCENTCLOUD_SECRET_ID'), secret_key=os.environ.get('TENCENTCLOUD_SECRET_KEY') ) client = nlp_client.NlpClient(cred, "ap-guangzhou") req = models.SentimentAnalysisRequest() req.Text = "今天天气真好" resp = client.SentimentAnalysis(req) print(resp.to_json_string()) except TencentCloudSDKException as e: print(e)
Debug
Known issues
gotchaThe 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.
fix
pip install tencentcloud-sdk-python-common tencentcloud-sdk-python-nlp
affects: all
breakingIn 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.
fix
Use from tencentcloud.nlp.v20190408 import models
affects: 3.x
gotchaMany API request objects require explicitly setting all fields. Forgetting to set required fields (like Text in SentimentAnalysisRequest) will cause a MissingParameter error.
fix
Always check the official API documentation for required fields and set them before calling the method.
affects: all
Errors
Common errors & fixes
ModuleNotFoundError: No module named 'tencentcloud'
Common package not installed
fix
pip install tencentcloud-sdk-python-common
ImportError: cannot import name 'SentimentAnalysisRequest' from 'tencentcloud.nlp.models'
Wrong import path; models are under versioned subpackage
fix
from tencentcloud.nlp.v20190408 import models
Upgrade
Version history
3.1.80latest on PyPI · released Apr 16, 2026
Audit
Dependencies
tencentcloud-sdk-python-commonrequiredCommon base SDK required for client initialization and authentication
Agent activity
37 hits · last 30 days
node
32
OpenAI (training)
1
Resources