All Products
Search
Document Center

Object Storage Service:Installation (Python SDK V1)

Last Updated:Aug 08, 2025

You can install the OSS Python SDK to manage OSS buckets, upload and download files, manage data, or perform image processing. This topic describes how to install the OSS Python SDK.

Prerequisites

  1. 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.

    Note

    When you install the Python SDK in a Windows environment, make sure that your Visual C++ version is 15.0 or later.

  2. After the installation is complete, run the following command to check the Python version.

    python --version

    The following example shows a successful response, which indicates that Python 3.8.2 is installed.

    Python 3.8.2

Download the SDK

Install python-devel

After you complete the prerequisites, install the python-devel package.

Note

The OSS Python SDK requires crcmod to calculate cyclic redundancy check (CRC) codes. crcmod depends on the Python.h file in the python-devel package. If the Python.h file is missing from your system, the installation of the OSS Python SDK does not fail. However, the installation of the C extension pattern for crcmod fails. If the C extension pattern for crcmod fails to install, the pure Python pattern is used for CRC data validation during file uploads and downloads. The performance of the pure Python pattern is much lower than that of the C extension pattern. This reduces the efficiency of operations such as uploads and downloads.

Windows

When you install Python on Windows, the dependent header files are also installed. You do not need to install python-devel.

macOS

When you install Python on macOS, the dependent 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 using one of the following methods.

pip

  1. Install pip.

    pip is installed by default with Python 2.7.9 or later and Python 3.4 or later.

  2. Run the following command to install the latest version of the OSS Python SDK.

    pip install oss2                   

Source code

  1. Download the latest version of the OSS Python SDK from GitHub. Decompress the package, navigate to the folder, and make sure that the setup.py file exists in the folder.

    To download a historical version of the OSS Python SDK, see Historical versions.

  2. Run the following command to install the OSS Python SDK.

    python setup.py install                   

Verify the SDK

After you install the SDK, perform the following steps to verify the installation.

  1. Run the following command to enter the Python environment.

    python
  2. Run the following command to check the version of the OSS Python SDK.

    import oss2
    oss2.__version__                         

    The following example shows a successful response, which indicates that OSS Python SDK 2.18.3 is installed.

    '2.18.3'

FAQ

Error: No module named _crcfunext

Symptom

Uploads and downloads that use the OSS Python SDK are much slower than when you use other tools, such as ossutil or other SDKs.

Cause

When crcmod is compiled, the _crcfunext.so library is not generated because it depends on the Python.h file, which is missing from the system. For more information about crcmod, see crcmod introduction.

Solution

Verify that the C extension pattern for crcmod is installed.

  1. Run the following command to enter the Python environment.

    python
  2. Run the following command to import the _crcfunext C extension module from the crcmod module.

    import crcmod._crcfunext

    The following error message indicates that the C extension pattern for the crcmod library failed to install.

    Traceback (most recent call last):
    File "<stdin>", line 1, in <module>
    ImportError: No module named _crcfunext                                 
  3. Select a solution based on your operating system.

    Windows

    1. Download the crcmod-1.7.win32-py2.7.msi file or another version of the .msi file.

      Note

      The 32-bit version of crcmod is compatible with both 32-bit and 64-bit Windows systems.

    2. Install the .msi file. During the installation, specify the installation path for crcmod as the Lib\site-packages folder in your local Python installation path. For example, D:\python\Lib\site-packages\.

    3. After the installation is complete, verify crcmod again.

    Linux

    For Linux systems, if this issue occurs, perform the following steps:

    1. Run the following command to uninstall crcmod.

      pip uninstall crcmod
    2. Install python-devel. For more information, see Install python-devel.

    3. Run the following command to reinstall crcmod.

      pip install crcmod

      If the installation still fails, uninstall crcmod and run the following command to view the details of the failure.

      pip install crcmod -v

Error: No module named 'Crypto'

Symptom

The No module named 'Crypto' error is reported when you run the program.

Cause

The Crypto folder does not exist, or the crypto folder with a lowercase c exists.

Solution

Check whether the Crypto folder exists in your local Python installation path, for example, D:\python3.9\Lib\site-packages.

  • If the Crypto folder does not exist, run the following command.

    python -m pip install --upgrade setuptools
  • If the crypto folder (with a lowercase c) exists, rename it to Crypto and try to start the program again.

Error message: "is not recognized as an internal or external command"

In a Windows environment, if you receive the "is not recognized as an internal or external command" message, add the installation paths of Python and pip to the Path environment variable. The installation path of pip is usually the Scripts folder in the Python directory. After you edit the environment variable, you may need to restart your computer for the changes to take effect.

Failed to install the OSS Python SDK

If the installation of the OSS Python SDK fails, run the following command to uninstall and then reinstall it.

pip uninstall oss2            

How to upgrade the OSS Python SDK

Run the following command to upgrade the OSS Python SDK.

 pip install --upgrade oss2