打包应用程序后运行 python-shell 电子应用程序时出错(通过使用电子生成器)

时间:2021-05-19 15:15:23

标签: python electron

错误:

错误加载 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 有关。

生成的 .AppImage 工作正常!! 但是当我安装 snap 包时,它给了我这个错误。

蟒蛇构建:

我使用 pyinstaller 构建 python 文件,并将可执行文件发送到打包的应用程序。

package.json 文件:

{
  "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"
  }
}

python-shell 代码:

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 })

0 个答案:

没有答案