Skip to main content

Installation and use of Python modules on smartCORE

smartCORE is delivered with a Python interpreter (v3.12) as standard, but only standard libraries are included. If you want to use external Python modules (e.g. NumPy), you must install them manually on your optiMEAS device. This tutorial shows you how to install and use NumPy in a remote plugin.

Download and install the module

First, we download the Python module we want to use to our local computer using pip. Make sure to specify the correct platform/architecture and Python version. You can determine both by connecting to your optiMEAS device via optiCONTROL using SSH and running "lscpu | grep Architecture" or "python3 --version".
Below is an example of a bash script that you can customize to download the specified modules to your PC and automatically copy them to your optiMEAS device.

#!/bin/env bash

set -ex

rm -rf ./target/
pip install --no-cache-dir --platform=manylinux_2_17_aarch64 --python-version=3.12 --only-binary=:all: --target target numpy msgpack
scp -r ./target root@${TARGET_IP}:/sde/

Importing modules into Python

To import modules from third-party providers, append the storage location to the "Path" environment variable before importing.

# Add the directory where we copied our libraries to the path
import sys
sys.path.append('/sde/target')

# so we can easily import them
import numpy as np