All Products
Search
Document Center

Tablestore:Install Tablestore SDK for Python

Last Updated:Mar 20, 2025

After you install Tablestore SDK for Python, you can call operations of the Tablestore SDK when you write code. This topic describes how to install Tablestore SDK for Python.

Prerequisites

  • Python 2 or Python 3 is available. For more information about the download path, visit Python download address.

    Important
    • Tablestore SDK for Python V6.0.0 or later supports Python 3 and no longer supports Python 2.

      We recommend that you use the following Python 3 versions: Python 3.8, Python 3.9, Python 3.10, Python 3.11, and Python 3.12.

    • If you want to use Python 2, we recommend that you use Tablestore SDK for Python V5.4.4 or earlier.

  • The Python development environment, such as PyCharm is installed.

Install Tablestore SDK for Python

You can install Tablestore SDK for Python by using pip, GitHub, or source code. Select a method based on your business requirements.

Important

If you want to access Tablestore resources over HTTPS, we recommend that you use the latest version of Tablestore SDK for Python and make sure that the version of OpenSSL is 0.9.8j or later. We recommend that you use OpenSSL 1.0.2d.

The release package for Tablestore SDK for Python contains the certifi package that you can directly install and use. To update the root certificate, download the latest root certificate from the official website of certifi.

Use pip to install Tablestore SDK for Python

Run the following command to use pip to install Tablestore SDK for Python:

sudo pip install tablestore

Use GitHub to install Tablestore SDK for Python

Run commands to download the Tablestore SDK for Python package from GitHub and install Tablestore SDK for Python.

Note

If Git is not installed, install Git before you perform the steps.

  1. Run the following command to download the Tablestore SDK for Python package:

    git clone https://github.com/aliyun/aliyun-tablestore-python-sdk.git
  2. Run the following command to go to the directory of the Tablestore SDK for Python installation package:

    cd aliyun-tablestore-python-sdk
  3. Run the following command to install Tablestore SDK for Python:

    sudo python setup.py  install              

Use source code to install Tablestore SDK for Python

Download Tablestore SDK for Python source code and install Tablestore SDK for Python.

  1. Download the SDK package and decompress it.

    Note

    For information about the download addresses of Tablestore SDK for Python packages of earlier versions, see Version history of Tablestore SDK for Python.

  2. Go to the directory where the Tablestore SDK for Python package is decompressed.

  3. Run the following command to install Tablestore SDK for Python:

    sudo python setup.py install       
Note

Some Protocol Buffers (Protobuf) versions are incompatible with the *pb2.py files in the current installation package. You can manually generate *pb2.py files to fix this issue. To manually generate *pb2.py files, perform the following steps:

  1. Use the current version of Protobuf to generate the code of the corresponding Protobuf files.

    protoc --python_out=.  tablestore/protobuf/search.proto
    protoc --python_out=.  tablestore/protobuf/table_store.proto
    protoc --python_out=.  tablestore/protobuf/table_store_filter.proto
  2. Change the .proto suffix of the three generated files to pb2.py and copy the files to the tablestore/protobuf/ directory in the installation directory to replace the existing *pb2.py files.

Verify Tablestore SDK for Python

Enter python on the CLI and press the Enter key. Then, run the following command to check the SDK version in the Python environment:

>>> import tablestore
>>> tablestore.__version__
'5.3.0'

Uninstall Tablestore SDK for Python

Use pip to uninstall Tablestore SDK for Python. Run the following command to uninstall Tablestore SDK for Python:

sudo pip uninstall tablestore