建设集团网站公司,重庆沙坪坝有什么好玩的,网站登陆口提交网站,贸易公司1.包的引用要用相对路径。
例#xff1a;
我的项目架构是
G: └── PPP └── pythonProject ├── main.py └── res └── load_file.py └── calculation_function.py └── keywords_config.json
原…1.包的引用要用相对路径。
例
我的项目架构是
G: └── PPP └── pythonProject ├── main.py └── res └── load_file.py └── calculation_function.py └── keywords_config.json
原来打包后运行时候会提示找不到pythonProject模块。
究其原因是我在main.py引用calculation_function和load_file时用的是
from pythonProject.res.load_file import load_config,.......
而只要改成
from res.load_file import load_config, .... 之后就可以正常运行了。
2.将json文件打包入单个.exe文件。
在命令行中使用 --add-data 标志指定资源文件的路径和目标路径。
pyinstaller -F --add-data G:\PPP\pythonProject\res\keywords_config.json;res main.py 参考资料
06 打包-导入模块问题_哔哩哔哩_bilibili