New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

python-spawn

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

python-spawn

Easiest way to execute python scripts from nodejs

latest
Source
npmnpm
Version
1.0.3
Version published
Maintainers
1
Created
Source

python-spawn

python-spawn Logo `python-spawn` is an npm package designed to bridge the gap between Node.js and Python, allowing Node.js applications to execute Python scripts seamlessly. This package simplifies the integration process by providing an easy-to-use interface for running Python code, functions, and scripts directly from Node.js.

Features

  • Automatic Python Command Detection: Determines the available Python command (python or python3) on the system.
  • Script Execution: Enables the execution of entire Python scripts or specific functions within scripts, with argument passing capability.
  • Asynchronous Support: Executes Python scripts asynchronously, returning results via Promises for better integration with modern JavaScript code.
  • Error Handling: Provides comprehensive error messages to aid in debugging.
  • Temporary Script Wrapping: Generates a temporary wrapper script for executing specific Python functions, ensuring clean execution and removal post-execution.

Installation

Install python-spawn using npm:

npm install python-spawn

Usage

Basic Usage

const { PythonExecutor } = require("python-spawn");

// Creating an Instance
const executor = new PythonExecutor();

// Executing a Python Script
executor
  .executeScript("/path/to/your/script.py")
  .then((result) => console.log(result))
  .catch((error) => console.error(error));

// Executing a Python Function withing a Script
executor
  .executeScript("/path/to/your/script.py", "function_name", ["arg1", "arg2"])
  .then((result) => console.log(result))
  .catch((error) => console.error(error));

Contributing

Contributions are welcome! Please refer to the Contributing Guidelines for detailed information.

License

This project is licensed under the MIT License.

Keywords

python

FAQs

Package last updated on 27 Feb 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts