If you want to manage Object Storage Service (OSS) buckets, upload and download objects, manage data, and perform image processing (IMG), install OSS SDK for Python first. This topic describes how to install OSS SDK for Python.
Preparations
Install Python.
OSS SDK for Python requires Python 2.6, 2.7, 3.3, 3.4, 3.5, 3.6, 3.7, 3.8, or later.
NoteWhen you install OSS SDK for Python on Windows, make sure that the version of Visual C++ is 15.0 or later.
Run the following command to check the Python version:
python --version
The following response indicates that Python 3.8.2 is installed:
Python 3.8.2
Download OSS SDK for Python
Install python-devel
After you prepare the environment, you must install the python-devel package first.
OSS SDK for Python uses the crcmod library to calculate the value of cyclic redundancy check (CRC). The crcmod library depends on the Python.h file in the python-devel package. If the Python.h file does not exist, the installation is not affected, but crcmod extensions in C fail to be installed. In this case, the Python-only mode is used to calculate the value of CRC and perform CRC-64 when you upload and download objects. As a result, operations such as object upload and download are performed in an inefficient manner.
Windows
When you install Python on Windows, the Python.h file is installed together with Python. Therefore, you do not need to install python-devel.
macOS
When you install Python on macOS, the Python.h file is installed together with Python. Therefore, 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 OSS SDK for Python
After you install python-devel, you can use one of the following methods to install OSS SDK for Python:
pip
Install pip.
For Python 2.7.9 or later and Python 3.4 or later, pip is installed by default.
Run the following command to install the latest version of OSS SDK for Python:
pip install oss2
Source code
Visit GitHub to download the latest version of OSS SDK for Python package. Decompress the package and check whether the setup.py file exists in the directory.
For more information about how to download an earlier version of OSS SDK for Python, see Historical versions.
Run the following command to install OSS SDK for Python:
python setup.py install
Verify whether OSS SDK for Python is installed
After you install OSS SDK for Python, perform the following steps to verify whether OSS SDK for Python is installed:
Run the following command to enter the Python environment:
python
Run the following command to check the version of OSS SDK for Python:
import oss2 oss2.__version__
The following response indicates that OSS SDK for Python 2.18.3 is installed.
'2.18.3'
FAQ
What do I do if the "No module named _crcfunext" error message is returned?
What do I do if the No module named 'Crypto' error message is returned?
What do I do if an error message indicating that the command is not an internal or external command is returned?
What do I do if OSS SDK for Python failed to be installed?
How do I upgrade OSS SDK for Python?
What to do next
After you install OSS SDK for Python, you need to configure access credentials. For more information, see Configure access credentials.