1. Description
When executing a Python script on the device (LEON_CSS processor) using DepthAI v2.32.0.0, importing standard library modules such as urllib.parse or http.client triggers a ModuleNotFoundError: No module named 'ipaddress'. This causes a cascading failure and ultimately crashes the device.
This is a regression, as the exact same code executes successfully and returns the expected output in DepthAI v2.31.1.0.
2. Minimal Reproducible Example
#!/usr/bin/env python3
import depthai as dai
print(f"depthai version: {dai.__version__}")
pipeline = dai.Pipeline()
# Script node
script = pipeline.create(dai.node.Script)
script.setProcessor(dai.ProcessorType.LEON_CSS)
script.setScript("""
import socket
import fcntl
import struct
import http.client
from urllib.parse import urlparse
def get_ip_address(ifname):
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
return socket.inet_ntoa(fcntl.ioctl(
s.fileno(),
-1071617759, # SIOCGIFADDR
struct.pack('256s', ifname[:15].encode())
)[20:24])
ip = get_ip_address('re0')
node.warn(f'IP of the device: {ip}')
node.io['end'].send(Buffer(32))
""")
xout = pipeline.create(dai.node.XLinkOut)
xout.setStreamName('end')
script.outputs['end'].link(xout.input)
# Connect to device with pipeline
with dai.Device(pipeline) as device:
device.getOutputQueue("end").get() # Wait for the "end" msg
3. Actual Behavior (v2.32.0.0)
The device crashes with the following critical error, indicating a missing standard library dependency:
depthai version: 2.32.0.0
[14442C101100FDD600] [169.254.1.222] [5.930] [Script(0)] [critical] ModuleNotFoundError: No module named 'ipaddress'
At:
/usr/lib/python3.9/importlib/_bootstrap.py(984): _find_and_load_unlocked
...
/usr/lib/python3.9/urllib/parse.py(39): <module>
...
/usr/lib/python3.9/http/client.py(71): <module>
<script>(5): <module>
[14442C101100FDD600] [169.254.1.222] [1790756352.460] [host] [warning] Device crashed, but no crash dump could be extracted.
Traceback (most recent call last):
File ".../script_get_ip.py", line 38, in <module>
device.getOutputQueue("end").get()
RuntimeError: Communication exception - possible device error/misconfiguration. Original message 'Couldn't read data from stream: 'end' (X_LINK_ERROR)'
4. Expected Behavior (v2.31.1.0)
In the previous version, the script executes without error, correctly resolving the IP address:
depthai version: 2.31.1.0
[14442C101100FDD600] [169.254.1.222] [6.029] [Script(0)] [warning] IP of the device: 192.168.0.12
5. Environment
- DepthAI Library Version: 2.32.0.0 (Failing), 2.31.1.0 (Passing)
- Device: OAK-D Pro PoE
- Host OS: Linux (Ubuntu)
- Python Version: Python 3.10 (on host)
6. Preliminary Analysis
The stack trace reveals that /usr/lib/python3.9/urllib/parse.py implicitly imports the ipaddress module . It appears that the device-side firmware bundled with DepthAI v2.32.0.0 has inadvertently omitted the ipaddress module from its standard library subset, whereas v2.31.1.0 included it. Restoring this module or documenting its removal in the device-side scripting limitations would resolve this regression.