How to Install and Start Working with the Python SDK

How to Install and Start Working with the Python SDK

Overview

This article provides a step-by-step guide on how to build, install, and run the Python SDK on both Linux and Windows systems.


1) Choose the Appropriate Python SDK Version

The Fairino Python SDK is released in multiple versions, with each version designed to be compatible with a specific WebAPP or simulator version.

You can find all available SDK releases at the following link:
https://github.com/FAIR-INNOVATION/fairino-python-sdk/releases


Make sure to select and install the SDK version that matches your WebAPP (or simulator) version to ensure proper compatibility and functionality.
Warning
Using wrong SDK Version that doesn't match with the webAPP version or simulator version will result unpredictable errors

SDK Version
WebAPP Version / Simulator Version
Release Link
2.2.4
3.9.4
2.2.3
3.9.3
2.2.1
3.9.1
2.2.0
3.9.0
2.1.7
3.8.7
2.1.4
3.8.4

2) Build the Python SDK (Linux)

After downloading the ZIP file, extract its contents. The package typically includes the SDK source code for both Windows and Linux operating systems.

Before using the SDK tools on your system, you need to build the required dynamic libraries—.so files for Linux or .pyd files for Windows.


2.1) build the python SDK for linux operating system

After extracting the files, navigate to the SDK directory. For example:
~/path/to/pythonSDK/fairino-python-sdk-2.2.3_robot3.9.3/linux/fairino
Info
Make sure to replace "/path/to/pythonSDK" with the actual path to your directory.

Next, open a terminal in the same location and install Cython using the following command:
Notes
pip install cython
After installing cython, now you can build the library by typing the following commands:
Notes
python setup.py build_ext --inplace

You should expect an output similar to the one shown below.


2.2) validate python SDK build for linux operating system 

to validate the installation is to launch the Python 3 interpreter and run the following commands:
Notes
python3 
Notes
from fairino import Robot 
Notes
print(Robot.__file__)

The response below indicate that you have successfully compiled the SDK locally 

  

2.2) configure the python SDK to be accessible globally.

To make the SDK accessible from anywhere on your system, you need to configure the environment so the Python interpreter can locate the SDK and its dynamic libraries without requiring you to be inside the SDK/fairino subfolder.

Open a terminal, then edit the .bashrc file:

Notes
nano ~/.bashrc

Add the following line at the end of the file:

Notesexport PYTHONPATH="${PYTHONPATH}:/path/to/pythonSDK/fairino-python-sdk-2.2.4_robot_v3.9.4/linux/"

Info
Do not forget to replace /path/to/pythonSDK/ with the actual path to your directory.
Warning
Please make sure that the fairino subfolder is located under the linux folder and that the path ends with a trailing /. Otherwise, the export command may fail.


3) Build the Python SDK (Windows 10/11)

After downloading the ZIP file, extract its contents. The package typically includes the SDK source code for both Windows and Linux operating systems.

Before using the SDK tools on your system, you need to build the required dynamic libraries—.so files for Linux or .pyd files for Windows.

3.1) Build the Python SDK (Windows 10/11)

After downloading and extracting the ZIP file, navigate to the directory:

C:\[Your_path_to_sdk]\fairino-python-sdk-2.2.4_robot_v3.9.4\windows\fairino

Once inside this folder, open a terminal and run the following command:
Notes
pip install cython











Before proceeding to the next step and building the python dynamic library you will need to install  Microsoft C++ Build Tools - Visual Studio
Info
you will have to install the C++ workload which normally requires around 7 GB

After installing the Visual Studio Build Tools, select Desktop development with C++, then click Install to proceed.


Now you can build the dynamic library using the following command:

Notes
python setup.py build_ext --inplace  

After running this command, you should see output similar to the one shown below in the console.



3.2) Validate the Python SDK Build (Windows 10/11)


You can verify that the build process has succeeded by navigating to the Windows subfolder, launching the Python interpreter, and attempting to import the robot module, as shown in the screenshot below.
 

3.3) Set Up Global Access for the Python SDK (Windows 10/11)

To ensure the Python SDK can be used globally, you need to configure environment variables.

From the Start menu, search for “Edit the system environment variables”, then open it. In the System Properties window, click Environment Variables.

Under System variables (or User variables), click New, then create a variable named PYTHONPATH.

For the value, add the path to your Python SDK, for example:

\path\to\python\sdk\windows

Info
Make sure to replace this with the actual location of your SDK installation.