Jump to content

Setting up Python on RutOS

From Teltonika Networks Wiki
Main Page > General Information > Configuration Examples > Python > Setting up Python on RutOS

The information in this page is updated in accordance with 00.07.19.2 firmware version. .

Summary

This article contains instructions on how to set up python on your RUTX, RUTM, and RUTC series devices.

Python is a high-level programming language that enables users to run scripts and extend the device's functionality. The Python3 package can be installed via the WebUI or command line. The base installation can be expanded with optional tools like pip and virtualenv for managing packages and environments.

Note: The user is fully responsible for any actions, code, or scripts run on the device. Only the installation package and basic setup instructions are provided.

Prerequisites

  1. A RUTX, RUTM or RUTC series device
  2. At least 20 MB of free storage space for the base Python installation
    • additional 15 MB is required for pip
    • additional 20 MB is required for virtualenv
  3. An active internet connection (required only when installing pip and virtualenv)

Note: Actual storage requirements may vary depending on your specific device configuration, installed packages, and other running services. The sizes listed above should be used as general estimates only.

Installation

Installing the Python package

  1. Log in to the WebUI interface of your device.
  2. Navigate to System → Package Manager.
  3. Locate and install the Python3 package.
  • You can install it directly via the internet by selecting Install, or upload the package manually using the Upload Package option.
1556x528
1556x528
  • Alternatively, Python can be installed via SSH or the Command Line Interface (CLI) by running:
opkg update
opkg install python3

Installing PIP

PIP is a tool for installing and managing python packages. To install pip, connect to your device via SSH or CLI (accessible under System → Maintenance → CLI) and run the following commands:

wget https://bootstrap.pypa.io/get-pip.py
python3 get-pip.py
1658x351
1658x351

After completion, your device will have pip package manager ready to use.


Setting up a virtual environment

When using python or PIP, you may encounter the following warning:

1658x35
1658x35

If virtual environments are required, install and use virtualenv as a substitute for the venv module, as our Python package does not include venv by default. Run the following commands to install virtualenv and set up the virtual environment:

pip install virtualenv
python3 -m virtualenv venv
1658x412
1658x412

Summary

To confirm that Python is installed and functioning on your device, you can create and run a simple test script. For example, create a basic script using the following command:

echo 'print("Hello World from python!")' > test.py

Then execute the script with Python3:

python3 test.py

You should see the successful Hello World message:

527x62