All Products
Search
Document Center

Tablestore:Install Tablestore SDK for Python

Last Updated:Mar 27, 2024

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.

Prepare the environment

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

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

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 Tablestore SDK for Python package and decompress the package.

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