作者kerycheng (甚麽都不想做的凯瑞)
看板Python
标题Re: [问题] MEIPASS - No such file or directory er
时间Sun Jan 1 01:00:52 2023
※ 引述《imhandmore (imhandmore)》之铭言:
: 我用OpennCC模组制作程式码,我在IDE环境上面可以顺利执行
: 但等到我用pyinstaller 打包成exe之後就会显示下列错误:
: Traceback (most recent call last):
: File "converter2.py", line 20, in <module>
: File "opencc\opencc.py", line 55, in __init__
: File "opencc\opencc.py", line 106, in _init_dict
: FileNotFoundError: [Errno 2] No such file or directory: 'C:\\Users\\Claude\\AppData\\Local\\Temp\\_MEI151842\\opencc\\config\\s2tw.json'
: [20160] Failed to execute script converter2
: ----------------------------
: 我看stackoverflow的文章,加上adddata也是一样
: 目前苦恼不知道怎麽解决,请各位帮我想个办法,或者请私讯我 我可以提供报酬请你们帮忙解决
: -----
: Sent from JPTT on my Google Pixel 3a.
刚刚在写简转繁程式在打包的时候也是遇到同样问题
後来这找到这篇底下的留言
https://github.com/pyinstaller/pyinstaller-hooks-contrib/issues/296
bwoodsend commented on Aug 20, 2021
--collect-data=swagger_spec_validator should be all you need.
在打包的时候使用'--collect-data='这个指令
在pyinstaller的网页说明
--collect-data MODULENAME, --collect-datas MODULENAME
Collect all data from the specified package or module. This option can be
used multiple times.
也就是说不是
pyinstaller -F --add-data "s2twp.json" xxxx.py -w
而是
pyinstaller -F --collect-data=opencc xxxx.py -w
--
※ 发信站: 批踢踢实业坊(ptt.cc), 来自: 114.40.144.108 (台湾)
※ 文章网址: https://webptt.com/cn.aspx?n=bbs/Python/M.1672506054.A.879.html
1F:推 surimodo: 大师 01/01 18:05
2F:→ kerycheng: 球球= = 01/01 23:04