Installation (Python SDK V1)
To manage OSS buckets, upload and download files, manage data, or process images, you must first install the OSS Python SDK. This topic describes the installation process.
Prerequisites
Install Python.
The OSS Python SDK is compatible with Python versions 2.6, 2.7, 3.3, 3.4, 3.5, 3.6, 3.7, 3.8, and later.
NoteFor Windows, make sure that your Visual C++ version is 15.0 or later.
After the installation is complete, you can run the following command to check the Python version.
python --versionThe following example response indicates that Python 3.8.2 is installed.
Python 3.8.2
Download the SDK
For more information, see OSS API Documentation.
Install python-devel
After you prepare the environment, install the python-devel package.
The OSS Python SDK requires crcmod to perform cyclic redundancy check (CRC) calculations. crcmod depends on the Python.h file, which is included in the python-devel package. If the Python.h file is missing, the OSS Python SDK can still be installed, but the C extension for crcmod will fail to install. If the C extension fails to install, the SDK defaults to a pure Python mode for CRC data validation during uploads and downloads. The pure Python mode is significantly less efficient than the C extension and can slow down operations.
Windows
When you install Python on Windows, the required header files are also installed. You do not need to install python-devel.
macOS
When you install Python on macOS, the required header files are also installed. You do not need to install python-devel.
CentOS
Run the following command to install python-devel.
sudo yum install python-devel RHEL
Run the following command to install python-devel.
sudo yum install python-devel Fedora
Run the following command to install python-devel.
sudo yum install python-devel Debian
Run the following command to install python-devel.
sudo apt-get install python-dev Ubuntu
Run the following command to install python-devel.
sudo apt-get install python-dev Install the SDK
After you install python-devel, you can install the OSS Python SDK in one of the following ways.
pip
Install pip.
pip is installed by default with Python 2.7.9 and later, and Python 3.4 and later.
Run the following command to install the latest version of the OSS Python SDK.
pip install oss2
Source code
Download the latest version of the OSS Python SDK from GitHub. Decompress the package, navigate to the package directory, and confirm that the setup.py file is present.
To download a historical version of the OSS Python SDK, see Historical Versions.
Run the following command to install the OSS Python SDK.
python setup.py install
Verify the SDK
After you install the SDK, follow these steps to verify the installation.
Run the following command to enter the Python environment.
pythonRun the following command to check the OSS Python SDK version.
import oss2 oss2.__version__The following example response indicates that OSS Python SDK 2.18.3 is installed.
'2.18.3'