【问题标题】:How to deploy and run python scripts inside nodejs application? [closed]如何在 nodejs 应用程序中部署和运行 python 脚本? [关闭]
【发布时间】:2019-12-17 02:43:14
【问题描述】:

我正在使用一个 MEAN 堆栈应用程序,它将一个文件传递给 python 脚本,这个脚本执行一些任务,然后返回一些结果。 问题是,当我部署它时如何安装所需的 python 包?

谢谢!

我尝试使用 python shell 在 nodejs 应用程序中运行 python 代码。

【问题讨论】:

  • 使用子进程

标签: python node.js angular file mean-stack


【解决方案1】:
  • 将 python 脚本与 requirements.txt(包含你的 python 依赖项)一起放在你的 nodejs 项目中 目录。
  • 在部署期间,在 requirements.txt 和它上调用 pip install 应该为您安装软件包。

  • 您可以像任何 shell 命令一样从 nodejs 调用 python 脚本 使用 inbuild child_process 模块或 python-shell。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2016-11-29
    • 1970-01-01
    • 1970-01-01
    • 2021-05-12
    • 2021-12-25
    • 1970-01-01
    • 1970-01-01
    • 2017-06-30
    相关资源
    最近更新 更多