A newer version of this documentation is available.

View Latest

Full Installation

  • reference
March 16, 2025
+ 12
Installation instructions for the Couchbase Python Client.

This page covers installation of the SDK. A quick start guide in our Getting Started Guide should work for most users — and for anyone in a hurry to try out the SDK and our Hello World program, that page is usually the best place to get started — but more detailed installation instructions are provided here on this page for every supported platform. This guide assumes you have some familiarity with development using Python — if you are evaluating the SDK as a software architect, tester, or other non-Python role, you will benefit from our Platform Help page.

The Couchbase SDK 3.x API (used in the Python SDK 3.0 - 4.0) is a complete rewrite of the API, reducing the number of overloads to present a simplified surface area, and adding support for Couchbase Server features like Collections and Scopes (available from Couchbase Server 7.0).

3.x Python SDK introduced comprehensive PEP-484 style type annotations.

Requirements

Couchbase Python SDK bundles Couchbase++ automatically, so no need to install it separately. You may need CMake (a version >= 3.18) to install, although the installer will attempt to download it from PyPI automatically.

The Python SDK 4.x requires Python 3. See the Python Version Compatibility section for details on supported versions of Python.

Currently the Python Client source distribution requires the OpenSSL headers and libraries that the Python client itself was built against to be installed prior to the client itself. Additionally the installer relies on PEP517 which older versions of PIP do not support. If you experience issues installing it is advised to upgrade your PIP/setuptools installation as follows:

console
$ python3 -m pip install --upgrade pip setuptools wheel

Installation

Best practice is to use a Python virtual environment such as venv or pyenv to manage multible versions of Python, but in cases where this is not practicable follow the brew steps below, and also modify your $PATH as shown.

The Python SDK has wheels available on macOS for supported versions of Python.

There can be a problem when using the Python (3.8.2) that ships with Xcode on Catalina. It is advised to install Python via pyenv (see the Python SDK Github README for further details on pyenv installation), Homebrew, or python.org

To install the library on Mac OS, first install Homebrew.

Later versions of Mac OS can break the python3 homebrew installer. Simple mitigating steps may be found here.

The following example uses the Python supplied by the Homebrew package manager and not the vendor-supplied Python which ships with Mac OS. Once Homebrew is configured:

Get a list of the latest packages
console
$ brew update
Install compatible Python 3
console
$ brew install python3
For ZSH (MacOS 10.15 Catalina and newer)
console
$ echo 'export PATH="/usr/local/bin:"$PATH' >> ~/.zshrc
console
$ source ~/.zshrc

Install the latest Python SDK:

console
$ sudo -H python3 -m pip install couchbase
Starting with Python 3.11.5, macOS installers from python.org now use OpenSSL 3.0. If using a version prior to 4.1.9 of the Python SDK, a potential side-effect of this change is an ImportError: DLL load failed while importing pycbc_core error. Upgrade the SDK to a version >= 4.1.9 to avoid this side-effect. If unable to upgrade, a work-around is to set the PYCBC_OPENSSL_DIR environment variable to the path where the OpenSSL 1.1 libraries (libssl.1.1.dylib ` and `libcrypto.1.1.dylib) can be found.

PyPy support

Because the Python SDK is written primarily in C using the CPython API, the official SDK will not work on PyPy.