0

I'm trying to run a Python script within Javascript code and in order to do it, I need to have a virtual environment set up in Python.

I have a Python3.10 folder in the following directory ./stability/lib/python3.10

My current code is

const data_to_pass_in = '-W 512 -H 512 "A stunning house."';
const python_env = "./stability/lib/python3.10"

app.get("/api", (req, res) => {
    const python_process=spawner(python_env, ["./calculation.py", data_to_pass_in]);
    python_process.stdout.on('data', (data) => {
    console.log('Data recieved from python script:', data.toString());
    });
    console.log('Data sent to python script:', data_to_pass_in);
    res.sendFile(__dirname + "/file.png")
})

However when I run this, I get:

errno: -13,
  code: 'EACCES',
  syscall: 'spawn ./stability/lib/python3.10',
  path: './stability/lib/python3.10',
  spawnargs: [ './client.py', '-W 512 -H 512 "A stunning house."' ]

The Python code, client.py I am trying to execute is available here: https://github.com/Stability-AI/stability-sdk

Any help is appreciated!

Pajke
  • 347
  • 1
  • 3
  • 12
  • 2
    The error shows your node.js env doesn't have permission to run the python script. You need to change the permission of the script. Check [this](https://stackoverflow.com/questions/48910876/error-eacces-permission-denied-access-usr-local-lib-node-modules) link. – Apoorva Chikara Aug 28 '22 at 04:21
  • Hmm, the permissions are not root, they are my user and I'm still having the EACCESS error – Pajke Aug 28 '22 at 04:42
  • Are you sure that the path is correct? – Konrad Aug 28 '22 at 08:49

0 Answers0