virtualenv
Version:
install and use Python dependencies in node with virtualenv
20 lines (15 loc) • 534 B
JavaScript
var virtualenv = require("virtualenv");
var packagePath = require.resolve("./package.json")
var env = virtualenv(packagePath);
// This is a child_process running Python using your virtualenv. You can
// communicate with it over stdin/stdout, etc.
var child = env.spawnPython(["./temp.py"]);
child.stdout.on('data', (data) => {
console.log(`stdout: ${data}`);
});
child.stderr.on('data', (data) => {
console.log(`stderr: ${data}`);
});
child.on('close', (code) => {
console.log(`child process exited with code ${code}`);
});