2

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?

1 Answer 1

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)
Sign up to request clarification or add additional context in comments.

9 Comments

So I could even do more than one script = python.import('your_script_module_name'); lines to keep coding, right?
I got module in same folder and I get: Error: No module named python.taylorsum...
@diegoaguilar, Did you set PYTHONPATH=. as I did in the screencast?
I did, yes, being . the folder from where such an app.js is being started
@diegoaguilar, Do you have a python directory in the same directory? If so, does python directory is a package (having __init__.py)?
|

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.