Skip to content

ModuleNotFoundError: No module named \'onnxscript\' in test-py3x (3.11) pipeline #8620

@KumoLiu

Description

@KumoLiu
======================================================================
ERROR: test_onnx_export_0_True (tests.networks.test_bundle_onnx_export.TestONNXExport.test_onnx_export_0_True)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/runner/work/MONAI/MONAI/tests/test_utils.py", line 840, in command_line_tests
    normal_out = subprocess.run(cmd, env=test_env, check=True, capture_output=True)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/hostedtoolcache/Python/3.11.14/x64/lib/python3.11/subprocess.py", line 571, in run
    raise CalledProcessError(retcode, process.args,
subprocess.CalledProcessError: Command '['python', '-m', 'monai.bundle', 'onnx_export', 'network_def', '--filepath', '/tmp/tmppxnzhayg/model.onnx', '--meta_file', '/home/runner/work/MONAI/MONAI/tests/testing_data/metadata.json', '--config_file', "['/home/runner/work/MONAI/MONAI/tests/testing_data/inference.json','/tmp/tmppxnzhayg/def_args.yaml']", '--ckpt_file', '/tmp/tmppxnzhayg/model.pt', '--args_file', '/tmp/tmppxnzhayg/def_args.yaml', '--input_shape', '[1, 1, 96, 96, 96]', '--use_trace', 'True']' returned non-zero exit status 1.

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/opt/hostedtoolcache/Python/3.11.14/x64/lib/python3.11/site-packages/parameterized/parameterized.py", line 620, in standalone_func
    return func(*(a + p.args), **p.kwargs, **kw)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/runner/work/MONAI/MONAI/tests/networks/test_bundle_onnx_export.py", line 65, in test_onnx_export
    command_line_tests(cmd)
  File "/home/runner/work/MONAI/MONAI/tests/test_utils.py", line 846, in command_line_tests
    raise RuntimeError(f"subprocess call error {e.returncode}: {errors}, {output}") from e
RuntimeError: subprocess call error 1: b'Traceback (most recent call last):
  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "/home/runner/work/MONAI/MONAI/monai/bundle/__main__.py", line 31, in <module>
    fire.Fire()
  File "/opt/hostedtoolcache/Python/3.11.14/x64/lib/python3.11/site-packages/fire/core.py", line 135, in Fire
    component_trace = _Fire(component, args, parsed_flag_args, context, name)
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/hostedtoolcache/Python/3.11.14/x64/lib/python3.11/site-packages/fire/core.py", line 468, in _Fire
    component, remaining_args = _CallAndUpdateTrace(
                                ^^^^^^^^^^^^^^^^^^^^
  File "/opt/hostedtoolcache/Python/3.11.14/x64/lib/python3.11/site-packages/fire/core.py", line 684, in _CallAndUpdateTrace
    component = fn(*varargs, **kwargs)
                ^^^^^^^^^^^^^^^^^^^^^^
  File "/home/runner/work/MONAI/MONAI/monai/bundle/scripts.py", line 1426, in onnx_export
    _export(
  File "/home/runner/work/MONAI/MONAI/monai/bundle/scripts.py", line 1302, in _export
    net = converter(model=net, **kwargs)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/runner/work/MONAI/MONAI/monai/networks/utils.py", line 735, in convert_to_onnx
    torch.onnx.export(
  File "/opt/hostedtoolcache/Python/3.11.14/x64/lib/python3.11/site-packages/torch/onnx/__init__.py", line 282, in export
    from torch.onnx._internal.exporter import _compat
  File "/opt/hostedtoolcache/Python/3.11.14/x64/lib/python3.11/site-packages/torch/onnx/_internal/exporter/_compat.py", line 16, in <module>
    from torch.onnx._internal.exporter import (
  File "/opt/hostedtoolcache/Python/3.11.14/x64/lib/python3.11/site-packages/torch/onnx/_internal/exporter/_core.py", line 18, in <module>
    import onnxscript
ModuleNotFoundError: No module named \'onnxscript\'
', b"2025-11-03 04:29:44,189 - INFO - --- input summary of monai.bundle.scripts.onnx_export ---
2025-11-03 04:29:44,189 - INFO - > meta_file: '/home/runner/work/MONAI/MONAI/tests/testing_data/metadata.json'
2025-11-03 04:29:44,189 - INFO - > net_id: 'network_def'
2025-11-03 04:29:44,189 - INFO - > filepath: '/tmp/tmppxnzhayg/model.onnx'
2025-11-03 04:29:44,189 - INFO - > config_file: ['/home/runner/work/MONAI/MONAI/tests/testing_data/inference.json',
 '/tmp/tmppxnzhayg/def_args.yaml']
2025-11-03 04:29:44,189 - INFO - > ckpt_file: '/tmp/tmppxnzhayg/model.pt'
2025-11-03 04:29:44,189 - INFO - > use_trace: True
2025-11-03 04:29:44,190 - INFO - > input_shape: [1, 1, 96, 96, 96]
2025-11-03 04:29:44,190 - INFO - ---


torch_versioned_kwargs={}
"

======================================================================
ERROR: test_onnx_export_1_False (tests.networks.test_bundle_onnx_export.TestONNXExport.test_onnx_export_1_False)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/runner/work/MONAI/MONAI/tests/test_utils.py", line 840, in command_line_tests
    normal_out = subprocess.run(cmd, env=test_env, check=True, capture_output=True)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/hostedtoolcache/Python/3.11.14/x64/lib/python3.11/subprocess.py", line 571, in run
    raise CalledProcessError(retcode, process.args,
subprocess.CalledProcessError: Command '['python', '-m', 'monai.bundle', 'onnx_export', 'network_def', '--filepath', '/tmp/tmpvoqwnqw3/model.onnx', '--meta_file', '/home/runner/work/MONAI/MONAI/tests/testing_data/metadata.json', '--config_file', "['/home/runner/work/MONAI/MONAI/tests/testing_data/inference.json','/tmp/tmpvoqwnqw3/def_args.yaml']", '--ckpt_file', '/tmp/tmpvoqwnqw3/model.pt', '--args_file', '/tmp/tmpvoqwnqw3/def_args.yaml', '--input_shape', '[1, 1, 96, 96, 96]', '--use_trace', 'False']' returned non-zero exit status 1.

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/opt/hostedtoolcache/Python/3.11.14/x64/lib/python3.11/site-packages/parameterized/parameterized.py", line 620, in standalone_func
    return func(*(a + p.args), **p.kwargs, **kw)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/runner/work/MONAI/MONAI/tests/networks/test_bundle_onnx_export.py", line 65, in test_onnx_export
    command_line_tests(cmd)
  File "/home/runner/work/MONAI/MONAI/tests/test_utils.py", line 846, in command_line_tests
    raise RuntimeError(f"subprocess call error {e.returncode}: {errors}, {output}") from e
RuntimeError: subprocess call error 1: b'Traceback (most recent call last):
  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "/home/runner/work/MONAI/MONAI/monai/bundle/__main__.py", line 31, in <module>
    fire.Fire()
  File "/opt/hostedtoolcache/Python/3.11.14/x64/lib/python3.11/site-packages/fire/core.py", line 135, in Fire
    component_trace = _Fire(component, args, parsed_flag_args, context, name)
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/hostedtoolcache/Python/3.11.14/x64/lib/python3.11/site-packages/fire/core.py", line 468, in _Fire
    component, remaining_args = _CallAndUpdateTrace(
                                ^^^^^^^^^^^^^^^^^^^^
  File "/opt/hostedtoolcache/Python/3.11.14/x64/lib/python3.11/site-packages/fire/core.py", line 684, in _CallAndUpdateTrace
    component = fn(*varargs, **kwargs)
                ^^^^^^^^^^^^^^^^^^^^^^
  File "/home/runner/work/MONAI/MONAI/monai/bundle/scripts.py", line 1426, in onnx_export
    _export(
  File "/home/runner/work/MONAI/MONAI/monai/bundle/scripts.py", line 1302, in _export
    net = converter(model=net, **kwargs)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/runner/work/MONAI/MONAI/monai/networks/utils.py", line 735, in convert_to_onnx
    torch.onnx.export(
  File "/opt/hostedtoolcache/Python/3.11.14/x64/lib/python3.11/site-packages/torch/onnx/__init__.py", line 282, in export
    from torch.onnx._internal.exporter import _compat
  File "/opt/hostedtoolcache/Python/3.11.14/x64/lib/python3.11/site-packages/torch/onnx/_internal/exporter/_compat.py", line 16, in <module>
    from torch.onnx._internal.exporter import (
  File "/opt/hostedtoolcache/Python/3.11.14/x64/lib/python3.11/site-packages/torch/onnx/_internal/exporter/_core.py", line 18, in <module>
    import onnxscript
ModuleNotFoundError: No module named \'onnxscript\'
', b"2025-11-03 04:29:52,920 - INFO - --- input summary of monai.bundle.scripts.onnx_export ---
2025-11-03 04:29:52,920 - INFO - > meta_file: '/home/runner/work/MONAI/MONAI/tests/testing_data/metadata.json'
2025-11-03 04:29:52,920 - INFO - > net_id: 'network_def'
2025-11-03 04:29:52,920 - INFO - > filepath: '/tmp/tmpvoqwnqw3/model.onnx'
2025-11-03 04:29:52,920 - INFO - > config_file: ['/home/runner/work/MONAI/MONAI/tests/testing_data/inference.json',
 '/tmp/tmpvoqwnqw3/def_args.yaml']
2025-11-03 04:29:52,920 - INFO - > ckpt_file: '/tmp/tmpvoqwnqw3/model.pt'
2025-11-03 04:29:52,920 - INFO - > use_trace: False
2025-11-03 04:29:52,921 - INFO - > input_shape: [1, 1, 96, 96, 96]
2025-11-03 04:29:52,921 - INFO - ---


torch_versioned_kwargs={}
"

----------------------------------------------------------------------
Ran 14137 tests in 1235.674s

FAILED (errors=2, skipped=1061)

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions