Skip to content

Python SDK

The Classiq Python SDK package, classiq, allows access to the Classiq platform within Python.

Installation

To start using the Python SDK, install Python, version 3.8+ (64-bit). The Classiq SDK package is hosted on PyPI and can be installed with pip:

pip install -U classiq

Running this command in the terminal installs the latest version of the classiq Python package.

Updating Versions

You may use any of the active Classiq versions, as listed in Active Classiq Versions. It is strongly encouraged to always use the latest available version.

Update the classiq package using pip, similarly to installing it. To update classiq to the latest version, run this command:

pip install -U classiq

To update classiq to a specific version:

pip install classiq=={DESIRED_VERSION}

To verify that the correct version is installed:

pip show classiq

Authentication

To use the SDK you must perform authentication. Do it only once. (Calling it when the current device is already authenticated results in an error.)

Authentication is simple, and requires asynchronously calling the single authentication function, as shown in the example below.

import classiq

classiq.authenticate()

A confirmation window opens in your default browser:

Code confirmation screen

Make sure the user code shown in the window is the same as printed by the script. Press confirm. This login screen appears:

Login screen

Complete your login using one of the available options.

Once the authentication process is complete, the script concludes its run, and you can freely use the SDK on your current device.

Note that the authentication process and further automatic authentication attempts (that do not require user initiation) make use of your OS password management system (e.g., macOS Keychain, Windows Credential Locker). As a result, you are prompted by the OS to approve access to the classiqTokenService for your IDE.The password required is the one you ordinarily use to access your operating system, e.g., when unlocking your screen. See below for an example using macOS Keychain.

Access request window

Authentication on Headless Linux Systems

The authentication procedure on headless Linux systems stores the tokens locally in a credentials file. While you must still run the authentication once, it can be done on another system with a browser.

Imports Structure

The SDK package has an exposed imports structure. Import objects only from these public subpackages. The public submodules of a certain module are encoded in its dir entries. For example, to view the submodules of the package main module:

import classiq

print(dir(classiq))

To use the SDK correctly, do not access any submodules that are not public.