Tencent Cloud MVJ SDK for Python
raw JSON → 3.0.1416 verified Sat May 09 auth: no python
Official Tencent Cloud SDK for the Marketing Value Judgment (MVJ) service. Provides Python bindings to interact with Tencent Cloud MVJ APIs. Current version: 3.0.1416. Released irregularly alongside the broader tencentcloud-sdk-python.
pip install tencentcloud-sdk-python-mvj Common errors
error ModuleNotFoundError: No module named 'tencentcloud.mvj' ↓
cause The MVJ package is not installed, or you are trying to import directly from the top-level tencentcloud package.
fix
Install the service package: pip install tencentcloud-sdk-python-mvj
error ImportError: cannot import name 'MvjClient' from 'tencentcloud.mvj.v20190926' ↓
cause The class MvjClient is inside the mvj_client module, not directly in the version package.
fix
Import from tencentcloud.mvj.v20190926.mvj_client import MvjClient
error tencentcloud.common.exception.TencentCloudSDKException: [InvalidParameter] The secret key not valid. ↓
cause Missing or invalid SecretId/SecretKey in credentials.
fix
Set TENCENTCLOUD_SECRET_ID and TENCENTCLOUD_SECRET_KEY environment variables or pass correct credentials.
Warnings
gotcha The tencentcloud-sdk-python is composed of many small packages. Ensure you install the specific service package (tencentcloud-sdk-python-mvj) and also the common package (tencentcloud-sdk-python-common). ↓
fix Run: pip install tencentcloud-sdk-python-common tencentcloud-sdk-python-mvj
gotcha The correct import path includes the API version (v20190926). Attempting to import from tencentcloud.mvj directly will fail. ↓
fix Use: from tencentcloud.mvj.v20190926 import mvj_client
breaking SDK v3.x splits services into separate packages and changes import structures compared to v2.x. If upgrading from v2.x, all imports must be updated. ↓
fix Change imports from old v2 style to new v3 style as shown in the quickstart.
Imports
- MvjClient wrong
from tencentcloud.mvj import MvjClientcorrectfrom tencentcloud.mvj.v20190926 import mvj_client - MvjClient wrong
from tencentcloud.mvj.v20190926 import MvjClientcorrectfrom tencentcloud.mvj.v20190926.mvj_client import MvjClient
Quickstart
import os
from tencentcloud.common import credential
from tencentcloud.mvj.v20190926 import mvj_client, models
# Replace with your actual SecretId and SecretKey
cred = credential.Credential(
os.environ.get('TENCENTCLOUD_SECRET_ID', ''),
os.environ.get('TENCENTCLOUD_SECRET_KEY', '')
)
client = mvj_client.MvjClient(cred, "ap-guangzhou")
req = models.MarketingValueJudgementRequest()
params = {
"AccountType": 1,
"Uid": "test_uid",
"UserIp": "8.8.8.8",
"PostTime": 1234567890,
"AssociateAccount": "test_account",
"NickName": "test_nick",
"PhoneNumber": "1234567890",
"EmailAddress": "test@example.com",
"RegisterTime": 1234567890
}
req.from_json_string(params)
resp = client.MarketingValueJudgement(req)
print(resp.to_json_string())