You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Windows编写的Python代码在树莓派上调用NodeJS子进程失效解决方法

树莓派移植项目后subprocess调用Node脚本失败问题

原有代码

Windows端可正常运行的代码:

#Refresh the data by calling NodeJS API
subprocess.call(['node', r'C:\Users\david\GrowattAPI\write.js'], shell=True)

树莓派上调整脚本路径后的代码:

#Refresh the data by calling NodeJS API
subprocess.call(['node', '/home/pi/Documents/write.js'], shell=True)

异常情况

  • 代码内调用Node脚本执行失败
  • 树莓派终端手动执行node /home/pi/Documents/write.js可正常运行
  • 核心疑问:为何调整路径后代码调用失效?

最终解决方案

树莓派环境下该场景subprocess.call的正确写法为:

subprocess.call(['node /home/pi/Documents/write.js'], shell=True)

内容的提问来源于stack exchange,提问作者PradoEagle

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.10.27 19:06:02