Jump to content

Setting up Python on RutOS: Difference between revisions

From Teltonika Networks Wiki
No edit summary
No edit summary
Line 4: Line 4:
This article contains instructions on how to set up python on your '''RUTX''' and '''RUTM''' series devices.
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.
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.
'''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.
Line 11: Line 11:


#A '''RUTX''' or '''RUTM''' series device
#A '''RUTX''' or '''RUTM''' series device
#At least '''20 MB''' of free storage for the base '''Python''' installation
#At least '''20 MB''' of free storage space for the base '''Python''' installation
##'''35 MB''' total required for '''Python''' with '''pip'''
#*additional '''15 MB''' is required for '''pip'''
##'''55 MB''' total required for '''Python''' with '''pip''' and '''virtualenv'''
#*additional '''20 MB''' is required for '''virtualenv'''
#An '''active internet connection''' (required only for installing '''pip''' and '''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.
'''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.


Line 22: Line 22:
#Navigate to '''System → Package Manager'''.
#Navigate to '''System → Package Manager'''.
#Locate and install the '''Python3''' package.
#Locate and install the '''Python3''' package.
##You can install it directly via the internet by selecting '''Install''',
:*You can install it directly via the internet by selecting '''Install''', or upload the package manually using the '''Upload Package''' option.
or upload the package manually using the '''Upload Package''' option.


[[File:RutOS python package install.png|border|class=tlt-border|1556x528|center]]
[[File:RutOS python package install.png|border|class=tlt-border|1556x528|center]]


Alternatively, Python can be installed via '''SSH''' or the '''Command Line Interface (CLI) ''' by executing:
:*Alternatively, Python can be installed via '''SSH''' or the '''Command Line Interface (CLI) ''' by running:
<pre>opkg update</pre>
<pre>opkg update</pre>
<pre>opkg install python3</pre>
<pre>opkg install python3</pre>
Line 33: Line 32:
===Installing PIP===
===Installing PIP===
PIP is a tool for installing and managing python packages.
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:
To install pip, connect to your device via '''SSH''' or '''CLI''' (accessible under '''System → Maintenance → CLI''') and run the following commands:
<pre>wget https://bootstrap.pypa.io/get-pip.py</pre>
<pre>wget https://bootstrap.pypa.io/get-pip.py</pre>
<pre>python3 get-pip.py</pre>
<pre>python3 get-pip.py</pre>
Line 39: 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 installation, your device will have pip package manager ready for use.
After completion, your device will have pip package manager ready for use.
----
----
===Setting up a virtual environment===
===Setting up a virtual environment===
Line 46: 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 missing venv module. Run the following commands to 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>

Revision as of 09:22, 29 October 2025

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. 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 or RUTM 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 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 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 output of the Hello World message:

527x62