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.18.2 firmware version. .

Summary

This article contains instructions on how to set up python on your RUTX and RUTM 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, 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 or RUTM series device
  2. At least 20 MB of free storage for the base Python installation
    1. 35 MB total required for Python with pip
    2. 55 MB total required for Python with pip and virtualenv
  3. An active internet connection (required only for 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.
    1. 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 executing:

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 execute the following commands:

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

After installation, your device will have pip package manager ready for use.


Setting up a virtual environment

When executing pip commands, you may encounter the following warning:

1658x35
1658x35

If virtual environments are required, install and use virtualenv as a substitute for the missing venv module. Run the following commands to 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 output of the Hello World message:

527x62