Install SDK for Python
Introduction
Welcome to Zenlayer Cloud API Software Developer Kit (SDK). SDK is a supporting tool for Zenlayer Cloud API. It currently supports Bare Metal Instance, Elastic IP, DDoS Protected IP and other products. More cloud services will be supported for SDK.
Requirements
The python environment is installed. version 3.6 or later is used.
A Zenlayer Cloud account is created and an Access Key ID and an Access Key Password are created. See Generate an API Access Key for more details.
Installation
Installation with Pip (Recommended)
You can install the ZenlayerCloud API Python SDK into your project using the pip installation method. If your project environment does not have pip installed, please refer to the pip official website for detailed installation instructions.
To install or upgrade using pip, execute the following command in the command line:
Please note that if you have both Python 2 and Python 3 environments, the Python 3 environment should use the pip3
command for installation.
Installation from source
Go to the Github repository to download the latest code.
Examples
Take CreateInstances as an example.
More Configuration
Before creating a client, you can configure the values of fields in the Config if needed.
The specific configuration options are explained below:
Timeout
The SDK has a default timeout of 60 seconds. If needed, please refer to the code to get the latest default value. Unit: seconds
Debugging
You can enable debug mode, which will print more detailed logs (including request and response data). This can be useful for detailed error troubleshooting. Debug mode is disabled by default.
Default: False
Proxy
If you are in an environment with a proxy, you can set the proxy using the following method.
Certificate Issue
When installing Python 3.6 or above on the Mac operating system, you may encounter a certificate error: Error: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: self signed certificate in certificate chain (_ssl.c:1056)
. This is because on Mac OS, Python no longer uses the system's default certificates and does not provide its own certificates. When making HTTPS requests, it requires the use of certificates provided by the certifi
library. However, the SDK does not support specifying certificates, so the only solution is to install the certificates by running the command sudo "/Applications/Python 3.6/Install Certificates.command"
.
The Python SDK uses the certificates provided by the certifi
library by default. If you need to specify a certificate, you can do so with the following settings. If you want to skip certificate verification, pass False
as the value.
Last updated