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.
ImportantTablestore 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.
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.
If Git is not installed, install Git before you perform the steps.
Run the following command to download the Tablestore SDK for Python package:
git clone https://github.com/aliyun/aliyun-tablestore-python-sdk.git
Run the following command to go to the directory of the Tablestore SDK for Python installation package:
cd aliyun-tablestore-python-sdk
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.
Download the SDK package and decompress it.
NoteFor information about the download addresses of Tablestore SDK for Python packages of earlier versions, see Version history of Tablestore SDK for Python.
Go to the directory where the Tablestore SDK for Python package is decompressed.
Run the following command to install Tablestore SDK for Python:
sudo python setup.py install
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:
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
Change the .proto suffix of the three generated files to
pb2.py
and copy the files to thetablestore/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