extrabacon / python-shell

Run Python scripts from Node.js with simple (but efficient) inter-process communication through stdio
2.12k stars 224 forks source link

Python-Shell doesn't work when packaging an Electron app #296

Closed ekwong3 closed 1 year ago

ekwong3 commented 1 year ago

Edit: it looks like a weird thing about the python path going to a different path than the default one, and the modules weren't installed there. Ended up converting the script to exe instead

The Question: Hi! I'm currently working on an Electron project that uses Python-Shell. It works fine in development, but when I try to package the app using electron-forge, it seems to throw an error every time and doesn't run. Any ideas on how to fix this? My project is here: [https://github.com/ekwong3/word-editor]. Thanks!

Any relevant python/javascript code: Here's the code for the javascript: `const { PythonShell } = require("python-shell");

function editText({ folderPath, find, replace, keepCase, processSub }) { let options = { mode: "text", args: [folderPath, find, replace, keepCase, processSub], }; PythonShell.run("editor.py", options) .then(() => { mainWindow.webContents.send("file:done"); }) .catch(() => { mainWindow.webContents.send("file:error"); }); }`