美文网首页
pyinstaller: Unable to find /***

pyinstaller: Unable to find /***

作者: 生活就是爱 | 来源:发表于2020-05-19 10:31 被阅读0次

在用pyinstaller对python程序集进行打包的时候,遇到了下列报错信息

Unable to find /***/***/nltk_data when adding binary and data files.

一开始我只是简单的任务,单单少了一个文件夹,于是在他指明的位置创建了一个空文件夹
没想每当我创建了一个空文件夹,后面总会告诉我新的位置缺失文件
已经陷入死局,这种办法显然不行

经过一番探索后,最终找到了解决方案

首先找到hook-nltk.py这个文件
这个文件通常在你的pyinstaller的安装目录中,比如我的路径是这样的

/home/'computer_username'/anaconda3/envs/'env_name'/lib/python3.5/site-packages/PyInstaller/

我的hook-nltk.py打开是这个样子的

1:import nltk
2:from PyInstaller.utils.hooks import collect_data_files
3:
4:# add datas for nltk
5:datas = collect_data_files('nltk', False)
6:
7:# loop through the data directories and add them
8:for p in nltk.data.path:
9:     datas.append((p, "nltk_data"))
10:
11:# nltk.chunk.named_entity should be included
12:hiddenimports = ["nltk.chunk.named_entity"]

直接把第8行和第9行注释掉就可以了

有人说要把第5行改为datas = []
还有人说第8行和第9行注释掉之后,指定datas的路径
这两个答案参考资料里面都有提到,我没有去尝试,有兴趣的同学可以尝试一下

参考资料:
github:unable to find "C:\Users\user\nltk_data

相关文章

网友评论

      本文标题:pyinstaller: Unable to find /***

      本文链接:https://www.haomeiwen.com/subject/hxuvohtx.html