sklearn-onnx icon indicating copy to clipboard operation
sklearn-onnx copied to clipboard

Pyinstaller compatibility

Open skornel02 opened this issue 2 years ago • 1 comments

Hi, I am currently trying to compile the following simple python script to an executable with PyInstaller:

import skl2onnx
print("hello world!")

I am not very familiar with the ecosystem so I'm interested if this is something that may or may not even work or has anyone managed to make this work.

Output of the executable (on Windows w/ Python 3.7.1)
Traceback (most recent call last):
  File "test.py", line 1, in 
  File "", line 983, in _find_and_load
  File "", line 967, in _find_and_load_unlocked
  File "", line 677, in _load_unlocked
  File "PyInstaller\loader\pyimod02_importers.py", line 499, in exec_module
  File "skl2onnx\__init__.py", line 15, in 
  File "", line 983, in _find_and_load
  File "", line 967, in _find_and_load_unlocked
  File "", line 677, in _load_unlocked
  File "PyInstaller\loader\pyimod02_importers.py", line 499, in exec_module
  File "skl2onnx\convert.py", line 6, in 
  File "", line 983, in _find_and_load
  File "", line 967, in _find_and_load_unlocked
  File "", line 677, in _load_unlocked
  File "PyInstaller\loader\pyimod02_importers.py", line 499, in exec_module
  File "skl2onnx\common\_topology.py", line 35, in 
  File "", line 983, in _find_and_load
  File "", line 967, in _find_and_load_unlocked
  File "", line 677, in _load_unlocked
  File "PyInstaller\loader\pyimod02_importers.py", line 499, in exec_module
  File "skl2onnx\common\_container.py", line 89, in 
  File "skl2onnx\common\_container.py", line 49, in _get_operation_list
  File "inspect.py", line 973, in getsource
  File "inspect.py", line 955, in getsourcelines
  File "inspect.py", line 786, in findsource
OSError: could not get source code
[1788] Failed to execute script 'test' due to unhandled exception!
   

Thank you for your help in advance!

skornel02 avatar Oct 12 '22 06:10 skornel02

I guess inpsect expects to see physical files but pyinstaller removes the physical file. It could happen with other modules. The code using inpsect is just doing validation and could be disabled.

xadupre avatar Oct 13 '22 08:10 xadupre