Run python script in Electron app

后端 未结 2 676
没有蜡笔的小新
没有蜡笔的小新 2021-01-30 09:58

I have a Electron project which executes some python script using NodeJS\'s child_process module. My python script is in the root folder of my project.

Here\'s how I cal

2条回答
  •  终归单人心
    2021-01-30 10:14

    You can include the script in extraResources:

    "build": {
        "extraResources": "python_scripts",
    ...
    

    And then the dir will be at the app root:

    let python = spawn('python', [path.join(app.getAppPath(), '..', 'python_scripts/my_script.py'])
    

提交回复
热议问题