I've written python scripts for some numerical analysis topics and so I want to plot them in a nice way using any Java Script library.
So, I got to know about python-node and they show some brief doc info at that site:
var python = require('node-python');
var os = python.import('os');
// nodejs stuff
var path = require('path');
assert(os.path.basename(os.getcwd()) == path.basename(process.cwd()))
However, how could I start to actually do python, import python libraries, run python scripts, etc?
asked Feb 9, 2014 at 5:06
diegoaguilar
8,42616 gold badges88 silver badges134 bronze badges
1 Answer 1
That example show how to use import and call functions.
Try following:
var python = require('node-python');
var script = python.import('your_script_module_name');
script.your_function(argument1, argument2)
answered Feb 9, 2014 at 5:16
falsetru
371k69 gold badges770 silver badges660 bronze badges
Sign up to request clarification or add additional context in comments.
9 Comments
diegoaguilar
So I could even do more than one
script = python.import('your_script_module_name'); lines to keep coding, right?diegoaguilar
I got module in same folder and I get:
Error: No module named python.taylorsum...falsetru
@diegoaguilar, Did you set
PYTHONPATH=. as I did in the screencast?diegoaguilar
I did, yes, being
. the folder from where such an app.js is being startedfalsetru
@diegoaguilar, Do you have a
python directory in the same directory? If so, does python directory is a package (having __init__.py)? |
default