错误加载 Python 库 '/run/user/1000/snap.python-electron/_MEIUZj5LV/libpython3.8.so.1.0': dlopen: /lib/x86_64-linux-gnu/libm.so.6: version在 PythonShell.parseError 中找不到 `GLIBC_2.29'(/run/user/1000/snap.python-electron/_MEIUZj5LV/libpython3.8.so.1.0 需要)
它与 snap 和 GLIBC_2.29 有关。
我使用 pyinstaller 构建 python 文件,并将可执行文件发送到打包的应用程序。
{
"name": "python-electron",
"version": "1.0.0",
"description": "python electron app",
"main": "main.js",
"scripts": {
"start": "electron .",
"watch": "nodemon --exec electron .",
"reset": "git reset --hard",
"build": "electron-builder",
"buildWin": "electron-builder --win --x64"
},
"author": "Yosh",
"license": "ISC",
"build": {
"extraResources": [
{
"from": "pythonDist",
"to": "pythonDist"
}
]
}
,
"devDependencies": {
"electron": "^12.0.7",
"electron-builder": "^22.11.3",
"nodemon": "^2.0.7"
},
"dependencies": {
"python-shell": "^3.0.0"
}
}
const { PythonShell } = require("python-shell");
// console.log(process.resourcesPath);
const pythonSend = (arg) => {
var options = {
mode: "json",
pythonOptions: ["-u"],
pythonPath: process.resourcesPath + "/pythonDist/backend",
args: [JSON.stringify(arg)],
};
PythonShell.run(
process.resourcesPath + "/pythonDist/backend",
options,
(err, results) => {
if (err) throw err;
console.log(results[0])
}
);
};
pythonSend({ data: 10 })