Setting up Python on RutOS: Difference between revisions
No edit summary |
No edit summary |
||
| (6 intermediate revisions by the same user not shown) | |||
| Line 1: | Line 1: | ||
<p style="color:red">The information in this page is updated in accordance with [https://wiki.teltonika-networks.com/view/FW_%26_SDK_Downloads'''00.07. | <p style="color:red">The information in this page is updated in accordance with [https://wiki.teltonika-networks.com/view/FW_%26_SDK_Downloads'''00.07.19.2'''] firmware version. .</p> | ||
==Summary== | ==Summary== | ||
This article contains instructions on how to set up python on your '''RUTX''' and ''' | 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. | 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. | ||
| Line 10: | Line 10: | ||
==Prerequisites== | ==Prerequisites== | ||
#A '''RUTX''' or ''' | #A '''RUTX''', '''RUTM''' or '''RUTC''' series device | ||
#At least '''20 MB''' of free storage space for the base '''Python''' installation | #At least '''20 MB''' of free storage space for the base '''Python''' installation | ||
#*additional '''15 MB''' is required for '''pip''' | #*additional '''15 MB''' is required for '''pip''' | ||
| Line 38: | Line 38: | ||
[[File:RutOS python pip install.png|border|class=tlt-border|1658x351|center]] | [[File:RutOS python pip install.png|border|class=tlt-border|1658x351|center]] | ||
After completion, your device will have pip package manager ready | After completion, your device will have pip package manager ready to use. | ||
---- | ---- | ||
===Setting up a virtual environment=== | ===Setting up a virtual environment=== | ||
| Line 45: | Line 45: | ||
[[File:RutOS python common warning.png|border|class=tlt-border|1658x35|center]] | [[File:RutOS python common warning.png|border|class=tlt-border|1658x35|center]] | ||
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: | 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: | ||
<pre>pip install virtualenv</pre> | <pre>pip install virtualenv</pre> | ||
<pre>python3 -m virtualenv venv</pre> | <pre>python3 -m virtualenv venv</pre> | ||
| Line 56: | Line 56: | ||
Then execute the script with '''Python3''': | Then execute the script with '''Python3''': | ||
<pre>python3 test.py</pre> | <pre>python3 test.py</pre> | ||
You should see the successful | You should see the successful Hello World message: | ||
[[File:RutOS python testing example.png|border|class=tlt-border|527x62]] | [[File:RutOS python testing example.png|border|class=tlt-border|527x62]] | ||
[[Category:Python]] | |||
Latest revision as of 10:23, 1 December 2025
Main Page > General Information > Configuration Examples > Python > Setting up Python on RutOSThe 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
- A RUTX, RUTM or RUTC series device
- 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
- 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
- Log in to the WebUI interface of your device.
- Navigate to System → Package Manager.
- 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.

- 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

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:

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

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:
