{"id":23240,"library":"aliyun-python-sdk-vpc","title":"Aliyun VPC SDK for Python","description":"The official Alibaba Cloud VPC (Virtual Private Cloud) SDK for Python, version 3.0.48, released on 2024-01-01. Provides APIs to manage VPC resources such as VPCs, vSwitches, route tables, and NAT gateways. Part of the Alibaba Cloud Python SDK family with monthly releases.","status":"active","version":"3.0.48","language":"python","source_language":"en","source_url":"https://github.com/aliyun/aliyun-openapi-python-sdk/tree/master/aliyun-python-sdk-vpc","tags":["alibaba-cloud","vpc","sdk","cloud-infrastructure"],"install":[{"cmd":"pip install aliyun-python-sdk-vpc","lang":"bash","label":"Install via pip"}],"dependencies":[{"reason":"Required for authentication and HTTP transport","package":"aliyun-python-sdk-core-v3","optional":false}],"imports":[{"note":"Import must explicitly reference the class from the module, not just the module.","wrong":"from aliyunsdkvpc.request.v20160428 import CreateVpcRequest","symbol":"VpcRequest","correct":"from aliyunsdkvpc.request.v20160428.CreateVpcRequest import CreateVpcRequest"}],"quickstart":{"code":"from aliyunsdkcore.client import AcsClient\nfrom aliyunsdkvpc.request.v20160428.CreateVpcRequest import CreateVpcRequest\nimport os\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 = CreateVpcRequest()\nrequest.set_VpcName('my-vpc')\nrequest.set_CidrBlock('10.0.0.0/16')\nresponse = client.do_action_with_exception(request)\nprint(response.decode('utf-8'))","lang":"python","description":"Creates a VPC in cn-hangzhou region. Requires Alibaba Cloud credentials set in environment variables."},"warnings":[{"fix":"Use from aliyunsdkvpc.request.v20160428.<ApiName> import <ApiName>Request","message":"In version 3.0.0+, all request classes must be imported from version-specific modules (e.g., v20160428). Direct imports from aliyunsdkvpc.request are deprecated and will raise ImportError.","severity":"breaking","affected_versions":">=3.0.0"},{"fix":"Replace do_action() with do_action_with_exception()","message":"The method do_action() is deprecated in favor of do_action_with_exception(), which raises exceptions on API errors instead of returning error codes.","severity":"deprecated","affected_versions":">=3.0.0"},{"fix":"Pass region to AcsClient constructor; do not use set_RegionId on request","message":"The region ID must be specified when creating the client, not in each request. Setting region on the request object is ignored for VPC.","severity":"gotcha","affected_versions":"all"}],"env_vars":null,"last_verified":"2026-05-01T00:00:00.000Z","next_check":"2026-07-30T00:00:00.000Z","problems":[{"fix":"Install: pip install aliyun-python-sdk-vpc. Then import from aliyunsdkvpc.","cause":"The package is not installed or the import path is incorrect.","error":"ModuleNotFoundError: No module named 'aliyunsdkvpc'"},{"fix":"Use the full import: from aliyunsdkvpc.request.v20160428.CreateVpcRequest import CreateVpcRequest","cause":"Trying to import from the package without specifying the correct submodule path.","error":"AttributeError: module 'aliyunsdkvpc.request' has no attribute 'v20160428'"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}