question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Uncaught Error: spawn python3 ENOENT

See original GitHub issue

Hey,

I’m trying to use python shell with electron.

Everything works fine, when I’m running the app with electron ., but when I build it with electron-builder and run .app file, it doesn’t work and console is giving me:

Uncaught Error: spawn python3 ENOENT
    at Process.ChildProcess._handle.onexit (internal/child_process.js:246)
    at onErrorNT (internal/child_process.js:429)
    at processTicksAndRejections (internal/process/task_queues.js:81)

Do anyone have this experience and know hove to solve it?

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:6 (1 by maintainers)

github_iconTop GitHub Comments

2reactions
simondemeulecommented, May 17, 2021

@blahafrank @benjaminbaker-dev @lavchandaria

I have faced the exact same issue today. After a good headache I figured it out, so I thought I’d share what I did:

  • disabling ASAR — ASAR apparently doesn’t play well with added resource files
  • including the whole python virtual environment as a set of resource files, taking care to replace the default symlinked python binaries with a copy of them (this is a bad idea — see my reply below for a better solution)
  • inspecting the built app’s resources to verify all necessary files were present (on macOS, Show package contents > Contents > Resources > app; you can bring back the package.json from your original project and run npm start to confirm everything works as intended)
  • applying path.join(__dirname, filePath) for all relative filePath; the file system of the built application does not work with plain relative paths. This applies to everything; the targeted python environment itself, the python file, and any files accessed from within the spawned process. In my case, since my python process reached for some included files and I didn’t want to pass __dirname as an argument, I retrieved it from within python with pathlib.Path(__file__).parent.absolute() (this assumes the python file sits at the project root)

While trying to figure this out, debugtron was helpful in providing debug output for the built version of the app.

I am not quite sure of this but I believe fix-path may resolve the issue of linking python properly if you aren’t using a virtual environment — I have seen it mentioned around on StackOverflow regarding similar issues.

I know this is probably an old problem no longer relevant to the authors, but hopefully this helps some future internet people.

1reaction
benjaminbaker-devcommented, Mar 31, 2020

@blahafrank @develar Hey were you able to solve this ? I’m having the same issue with .app file on OSX. I’m pretty sure it’s related to PATH issues - because when I use python instead of python3 all is well. I tried to fix problem by editing /etc/paths and adding python3 but to no avail. @develar - any ideas ? where does child_process.spawn() get PATH from ? Thank you 😃

Read more comments on GitHub >

github_iconTop Results From Across the Web

spawn python ENOENT node.js in windows - Stack Overflow
When running the code on his windows machine it gives this stacktrace. events.js:174 throw er; // Unhandled 'error' event ^ Error: spawn python ......
Read more >
Midi Error: spawn python3 ENOENT (python not found ...
If I launch OSC using node, when I ask for the midi list, it doesn't show any information, if I launch the Mac...
Read more >
SLS Deploy Error in Python: Error: spawn python3.8 ENOENT
ubuntu@jumpboxAndawscli:/data/integrations$ sudo sls deploy --stage prod Serverless: Configuration warning at 'provider': unrecognized ...
Read more >
How I fixed "Error: spawn python ENOENT" when upgrading
I run node-red in Docker and use the node-red-contrib-python-function node. My instance got stuck in a reboot loop when I upgraded to node-red ......
Read more >
[Solved-5 Solutions] Error spawn enoent on node.js - Wikitechy
Spawn may emit the ENOENT error if the filename command (i.e, 'some-command') does not exist in at least one of the directories defined...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found