python - 如何在电子生成器构建中包含 python 文件?
问题描述
我正在使用 electron-builder 从 electronjs 构建一个应用程序(获取可安装的 .exe)。问题是在编译并启动程序后,在控制台中我收到以下消息:
C:\Users\User\anaconda3\python.exe: can't open file
'C:\Users\User\Desktop\ProxyChecker\gui\dist\win-unpacked\resources\app.asar\ProxyChecker.py': [Errno 2] No such file or directory
我在构建之前的文件夹结构如下所示:
/node_modules
/linkers --> linker.js
.gui.html
.main.js
.package.json
.preload.js
.ProxyChecker.py
.renderer.js
据我了解,问题出在 package.json 配置中。看起来像这样:
{
"name": "electron-quick-start",
"version": "1.0.0",
"description": "A minimal Electron application",
"main": "main.js",
"scripts": {
"start": "electron .",
"build-installer": "electron-builder"
},
"build": {
"extraResources": [
{
"from": "/",
"to": ""
}
],
"appId": "electron-quick-start",
"win": {
"target": ["nsis"]
},
"nsis": {
"uninstallDisplayName": "electron-quick-start",
"oneClick": false,
"allowToChangeInstallationDirectory": true
},
"files": [
"ProxyChecker.py",
"**/*"
]
},
"repository": "https://github.com/electron/electron-quick-start",
"keywords": [
"Electron",
"quick",
"start",
"tutorial",
"demo"
],
"author": "GitHub",
"license": "CC0-1.0",
"devDependencies": {
"electron": "^11.2.1",
"electron-packager": "^15.2.0"
},
"dependencies": {
"python-shell": "^0.4.0"
},
"asar": true,
"asarUnpack": [
"ProxyChecker.py"
]
}
我尝试过的事情:
- 添加“extraResources”以添加整个根目录或仅将“ProxyChecker.py”添加到“”(据我所知,这是根目录)
- 我尝试添加“文件”(您可以在我的配置中看到)。
- 我尝试添加“extraFiles”并在其中输入“ProxyChecker.py”。
- 我尝试添加“asarUnpack”:[“ProxyChecker.py”]
这些都没有帮助。
谢谢你的帮助。
解决方案
推荐阅读
- php - 是什么导致 Symfony 调用服务?
- python - 如何在python中以更好的方式将ECLAT算法的水平格式转换为垂直格式?
- ios - 无法推断通用参数“内容”
- javascript - async/await 如何在此代码段中工作?
- python - 为什么我的 if 语句打印我的 else 没有错误?
- android-jetpack-compose - 收到错误消息:@Composable 调用只能在 @Composable 函数的上下文中发生
- javascript - 如果客户端从客户端更改某些数据属性,如何处理?
- docker - 在 Docker 中将文件从容器复制到本地
- django - Django 中 /create_order/4 处的 AttributeError
- python - 有什么方法可以计算python中一个二维数组的减法值吗?