问题描述
我有一个使用 sqlite3 的 PyQt4 应用程序.我目前有两个单独的文件:一个 .py 文件和一个 .db 文件.最初,我使用 .py 文件并尝试创建一个可执行文件,只是使用这种想法可能会以某种方式链接,但是当我运行 .exe 时,它会在访问数据库相关代码时中断.如何让 pyinstaller 也包含数据库?
I've got a PyQt4 application which makes use of sqlite3. I have two seperate files currently: a .py file and a .db file. Originally I took the .py file and tried to create an executable just using that thinking maybe it would link somehow but when I run the .exe it breaks when it gets to database related code. How do I get pyinstaller to include the database as well?
推荐答案
您需要使用规范文件.查看文档.
You need to use a specfile. Have a look at the documentation.
pyinstaller 会自动创建这些文件.你只需要编辑它.查看文档中的示例.要添加 README 文件,您只需将元组(源、目标)添加到数据":
pyinstaller creates those file automatically. You just need to edit it. Have a look at the example from the docs. To add a README file you just need to add a tuple (source, destination) to 'datas':
a = Analysis(...
datas=[ ('src/README.txt', '.') ],
...
)
这篇关于如何让 pyinstaller 包含我的数据库?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!