在我的 javascript 代码中使用 spawn to 运行 python 时出现错误
I'm getting an error when using spawn to run python in my javascript code
我是运行javascript中的python脚本,但是出现错误。
Javascript代码:
const { spawn } = require("child_process");
const python = spawn(
"C:/Users/Murat/AppData/Local/Programs/Python/Python39/python.exe",
["../pythonScript/main.py"]
);
python.stdout.on("data", function (data) {
console.log("It worked");
});
python.stderr.on("data", (data) => {
console.error("stderr: ", data.toString());
});
Python代码:
import pandas as pd
dataset = pd.read_csv("Breast.csv")
print(dataset.shape)
错误:
enter image description here
您尝试访问的 csv 文件不存在或您当前的工作目录设置不正确。尝试输入 chdir("Path to folder with Breast.csv");
我是运行javascript中的python脚本,但是出现错误。
Javascript代码:
const { spawn } = require("child_process");
const python = spawn(
"C:/Users/Murat/AppData/Local/Programs/Python/Python39/python.exe",
["../pythonScript/main.py"]
);
python.stdout.on("data", function (data) {
console.log("It worked");
});
python.stderr.on("data", (data) => {
console.error("stderr: ", data.toString());
});
Python代码:
import pandas as pd
dataset = pd.read_csv("Breast.csv")
print(dataset.shape)
错误: enter image description here
您尝试访问的 csv 文件不存在或您当前的工作目录设置不正确。尝试输入 chdir("Path to folder with Breast.csv");