Skip to content

PTF Docker image installs incompatible Scapy versions (2.4.5 vs 2.7.0) causing ImportError with Python 3.14 #1163

Description

@navydieu

Hi ,
I encountered an issue while running the PTF linerate tests on Ubuntu 26.04 with Python 3.14.
The PTF Docker image appears to install two different Scapy versions:
In ptf/Dockerfile:

  • ARG SCAPY_VER=2.4.5
    In requirements_ptf:
  • scapy==2.7.0

As a result, TRex uses its bundled Scapy 2.4.5 from:
/external_libs/scapy-2.4.5
while Python imports another Scapy package from:
/usr/local/lib/python3.14/dist-packages/scapy

This leads to a mixed Scapy environment, error log:

[root@BBU_5G_SYS-110P-FDWTR-363 ptf]# ./run_tests -t tests/linerate/ baseline.DonwlinkPerformanceBaselineTest
++ pwd
+ TEST_DIR=/home/vydlt1/opensource5g/upf_dpdk_2604/ptf
+ getopts t: flag
+ case "${flag}" in
+ testdir=tests/linerate/
+ getopts t: flag
+ testName=baseline.DonwlinkPerformanceBaselineTest
+ runName=ptf-24313
+ source .env
++ TESTER_DOCKER_IMG=bess-upf-ptf
++ UPF_ADDR=172.19.20.227:10514
++ TREX_ADDR=172.19.20.226
+ echo '*** Starting tests in container (ptf-24313)...'
*** Starting tests in container (ptf-24313)...
++ test -t 0
++ echo -it
+ it=-it
+ docker run --name ptf-24313 -it --privileged -v /home/vydlt1/opensource5g/upf_dpdk_2604/ptf:/upf-tests/ -v /home/vydlt1/opensource5g/upf_dpdk_2604/ptf/log:/tmp bess-upf-ptf python3 -u /upf-tests/lib/ptf_runner.py --ptf-dir /upf-tests/tests/linerate/ --trex-address 172.19.20.226 --bess-address 172.19.20.227:10514 --trex-config /upf-tests/config/trex-cfg-for-ptf.yaml --xunit --xunit-dir /tmp/ptf-logs baseline.DonwlinkPerformanceBaselineTest
/trex_python/trex_stf_lib/trex_client.py:1481: SyntaxWarning: "\d" is an invalid escape sequence. Such sequences will not work in the future. Did you mean "\\d"? A raw string is also an option.
  return len(self.get_last_value('trex-global.data', 'opackets-\d+'))
/trex_python/trex_stf_lib/trex_client.py:1505: SyntaxWarning: "\w" is an invalid escape sequence. Such sequences will not work in the future. Did you mean "\\w"? A raw string is also an option.
  self._expected_tx_rate = CTRexResult.__get_value_by_path(latest_dump, "trex-global.data", "m_tx_expected_\w+")
/trex_python/trex_stf_lib/trex_client.py:1507: SyntaxWarning: "\w" is an invalid escape sequence. Such sequences will not work in the future. Did you mean "\\w"? A raw string is also an option.
  self._current_tx_rate = CTRexResult.__get_value_by_path(latest_dump, "trex-global.data", "m_tx_(?!expected_)\w+")
/trex_python/trex_stf_lib/trex_client.py:1598: SyntaxWarning: "\d" is an invalid escape sequence. Such sequences will not work in the future. Did you mean "\\d"? A raw string is also an option.
  reg_res = re.match("avg-(\d+)", key)
/trex_python/trex_stf_lib/trex_client.py:1612: SyntaxWarning: "\d" is an invalid escape sequence. Such sequences will not work in the future. Did you mean "\\d"? A raw string is also an option.
  reg_res = re.match("avg-(\d+)", key)
2026-06-22 07:53:36,601 INFO Starting TRex daemon client...
2026-06-22 07:53:36,601 INFO Pushing TRex config /upf-tests/config/trex-cfg-for-ptf.yaml to the server
2026-06-22 07:53:51,656 INFO Running linerate test(s)...
Device "ptfdummy" does not exist.
net.ipv6.conf.ptfdummy.disable_ipv6 = 1
2026-06-22 07:53:51,707 INFO Executing PTF command: ptf --test-dir /upf-tests/tests/linerate/ --pypath /upf-tests/lib -i 296@ptfdummy --test-params=bess_upf_addr='172.19.20.227:10514';trex_server_addr='172.19.20.226' --xunit --xunit-dir /tmp/ptf-logs baseline.DonwlinkPerformanceBaselineTest
Using packet manipulation module: ptf.packet_scapy
/trex_python/trex/utils/common.py:352: SyntaxWarning: "\d" is an invalid escape sequence. Such sequences will not work in the future. Did you mean "\\d"? A raw string is also an option.
  return [int(c) if c.isdigit() else c for c in re.split('(\d+)', val)]
/trex_python/trex/utils/parsing_opts.py:35: SyntaxWarning: "\d" is an invalid escape sequence. Such sequences will not work in the future. Did you mean "\\d"? A raw string is also an option.
  match = re.match("^(\d+(\.\d+)?)([m|h]?)$", val)
/trex_python/trex/utils/parsing_opts.py:88: SyntaxWarning: "\d" is an invalid escape sequence. Such sequences will not work in the future. Did you mean "\\d"? A raw string is also an option.
  pattern = "^(\d+(\.\d+)?)(((k|m|g)?(bpsl1|pps|bps))|%)?"
/trex_python/trex/utils/parsing_opts.py:96: SyntaxWarning: "\+" is an invalid escape sequence. Such sequences will not work in the future. Did you mean "\\+"? A raw string is also an option.
  pattern += "([\+\-])?$"
/trex_python/trex/utils/parsing_opts.py:373: SyntaxWarning: "\S" is an invalid escape sequence. Such sequences will not work in the future. Did you mean "\\S"? A raw string is also an option.
  m = re.search('(\S+)=(.+)', token)
/trex_python/trex/common/trex_subscriber.py:113: SyntaxWarning: "\-" is an invalid escape sequence. Such sequences will not work in the future. Did you mean "\\-"? A raw string is also an option.
  m = re.search('(.*)\-([0-8])', key)
Traceback (most recent call last):
  File "/usr/local/bin/ptf", line 760, in <module>
    test_modules = load_test_modules(config)
  File "/usr/local/bin/ptf", line 577, in load_test_modules
    mod = import_module(root, modname)
  File "/usr/local/bin/ptf", line 119, in import_module
    return module_specs.loader.load_module()
           ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^
  File "<frozen importlib._bootstrap_external>", line 407, in _check_name_wrapper
  File "<frozen importlib._bootstrap_external>", line 940, in load_module
  File "<frozen importlib._bootstrap_external>", line 764, in load_module
  File "<frozen importlib._bootstrap>", line 540, in _load_module_shim
  File "<frozen importlib._bootstrap>", line 969, in _load
  File "<frozen importlib._bootstrap>", line 938, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 759, in exec_module
  File "<frozen importlib._bootstrap>", line 491, in _call_with_frames_removed
  File "/upf-tests/tests/linerate/baseline.py", line 9, in <module>
    from grpc_test import *
  File "/upf-tests/lib/grpc_test.py", line 19, in <module>
    from trex_test import TrexTest
  File "/upf-tests/lib/trex_test.py", line 6, in <module>
    from trex.stl.api import STLClient
  File "/trex_python/trex/stl/api.py", line 7, in <module>
    from .trex_stl_client import STLClient, PacketBuffer
  File "/trex_python/trex/stl/trex_stl_client.py", line 14, in <module>
    from ..common.trex_client import TRexClient, PacketBuffer
  File "/trex_python/trex/common/trex_client.py", line 39, in <module>
    from .services.trex_service_ipv6 import ServiceICMPv6, ServiceIPv6Scan
  File "/trex_python/trex/common/services/trex_service_ipv6.py", line 4, in <module>
    from ...stl.trex_stl_packet_builder_scapy import *
  File "/trex_python/trex/stl/trex_stl_packet_builder_scapy.py", line 13, in <module>
    from scapy.all import *
  File "/external_libs/scapy-2.4.5/scapy/all.py", line 17, in <module>
    from scapy.arch import *
  File "/external_libs/scapy-2.4.5/scapy/arch/__init__.py", line 118, in <module>
    from scapy.arch.linux import *  # noqa F403
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/external_libs/scapy-2.4.5/scapy/arch/linux.py", line 29, in <module>
    from scapy.arch.common import (
    ...<4 lines>...
    )
ImportError: cannot import name 'get_if' from 'scapy.arch.common' (/usr/local/lib/python3.14/dist-packages/scapy/arch/common.py)
2026-06-22 07:53:52,975 ERROR Failed to run linerate tests!

Could you please advise the recommended fix for this issue?

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Fields

No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions