Reputation: 1
I am encountering an issue when trying to run an Electron application that utilizes child_process.execFile
to execute a Python script. The Python script is wrapped into an executable file using PyInstaller. Within the Python script, I have imported the rembg library, which is used to remove the background from an image.
import rembg
print("Hello World")
When I run the Electron application and trigger the child_process.execFile command
to execute the Python script, I receive an error message. The error is displayed as
error: Command failed: Depend/test img2.jpg 6
Traceback (most recent call last):
File "test.py", line 1, in <module>
File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 688, in _load_unlocked
File "PyInstaller/loader/pyimod02_importers.py", line 352, in exec_module
File "rembg/__init__.py", line 5, in <module>
File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 688, in _load_unlocked
File "PyInstaller/loader/pyimod02_importers.py", line 352, in exec_module
File "rembg/bg.py", line 16, in <module>
File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 688, in _load_unlocked
File "PyInstaller/loader/pyimod02_importers.py", line 352, in exec_module
File "pymatting/__init__.py", line 3, in <module>
File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 688, in _load_unlocked
File "PyInstaller/loader/pyimod02_importers.py", line 352, in exec_module
File "pymatting/laplacian/__init__.py", line 5, in <module>
File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 688, in _load_unlocked
File "PyInstaller/loader/pyimod02_importers.py", line 352, in exec_module
File "pymatting/laplacian/lbdm_laplacian.py", line 6, in <module>
File "numba/core/decorators.py", line 241, in wrapper
File "numba/core/dispatcher.py", line 946, in compile
File "numba/core/caching.py", line 635, in load_overload
File "numba/core/caching.py", line 642, in _load_overload
File "numba/core/caching.py", line 485, in load
File "numba/core/caching.py", line 502, in _load_index
EOFError: Ran out of input
[25251] Failed to execute script 'test' due to unhandled exception!
However, if I run the Python script directly from my Linux terminal without involving Electron or child_process.execFile
, it runs smoothly and does not display any errors, regardless of whether or not I use the rembg library.
My goal is to resolve this error and successfully run the Electron application with the Python script, which includes the rembg library.
I tried changing the file name of the Python script, hoping to eliminate any conflicts or naming issues that may have caused the error. However, this didn't resolve the problem. I explored other methods provided by the child_process
module in Electron, such as spawn
, exec
, and execFile
.
Upvotes: 0
Views: 129
Reputation: 1
I force about same problem using pyinstaller and rembg.
try use:
pip install auto-py-to-exe
auto-py-to-exe
it help me.
Upvotes: 0