首页 > 解决方案 > How to spawn Python process from Heroku Node

问题描述

Am trying to execute a Python script from node. It's hitting the endpoint, and runs fine locally but when I try deploy from Heroku, I get the following error log:

```

2018-10-10T01:00:14.689410+00:00 app[web.1]: events.js:183
2018-10-10T01:00:14.689416+00:00 app[web.1]:       throw er; // Unhandled 'error' event
2018-10-10T01:00:14.689417+00:00 app[web.1]:       ^
2018-10-10T01:00:14.689419+00:00 app[web.1]: 
2018-10-10T01:00:14.689421+00:00 app[web.1]: Error: spawn python3.6 ENOENT
2018-10-10T01:00:14.689424+00:00 app[web.1]:     at Process.ChildProcess._handle.onexit (internal/child_process.js:190:19)
2018-10-10T01:00:14.689426+00:00 app[web.1]:     at onErrorNT (internal/child_process.js:362:16)
2018-10-10T01:00:14.689428+00:00 app[web.1]:     at _combinedTickCallback (internal/process/next_tick.js:139:11)

```

I tried setting the Python runtime in runtime.txt in the root directory:

```

$ cat runtime.txt

python-3.6.0

```

标签: pythonnode.jsherokuprocessspawn

解决方案


To answer my own question, the reason was I needed to add the Python buildpack alongside the NodeJS buildback. Discussed here: https://stackoverflow.com/a/39947385/3268182


推荐阅读