I am loading pythonia from a node host process.
I ran into a problem where I could not import python code written locally in my code. I can import modules from my virtual environment, but not locally written python code.
To solve, I needed to set PYTHONPATH, but there was no way to do this with the current code.
I worked around it by patching the IpcPipeCom.js file to pass through environment variables:
|
this.proc = cp.spawn(process.env.PYTHON_BIN || 'python3', args, { stdio }) |
this.proc = cp.spawn(process.env.PYTHON_BIN || 'python3', args, {
stdio,
// propagate
env: process.env
})
Then, i can set any environment variables in my node process and have them influence the child python process.
process.env.PYTHONPATH = rootDir;
I am loading
pythoniafrom a node host process.I ran into a problem where I could not import python code written locally in my code. I can import modules from my virtual environment, but not locally written python code.
To solve, I needed to set PYTHONPATH, but there was no way to do this with the current code.
I worked around it by patching the
IpcPipeCom.jsfile to pass through environment variables:JSPyBridge/src/pythonia/IpcPipeCom.js
Line 17 in ed32525
Then, i can set any environment variables in my node process and have them influence the child python process.