nltk-hook无法找到nltk_data [英] nltk-hook unable to find nltk_data

查看:263
本文介绍了nltk-hook无法找到nltk_data的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用pyinstaller构建可执行文件时,我得到

When using pyinstaller to build an executable I get

找不到/home/usr/nltk_data

unable to find /home/usr/nltk_data

添加二进制文件和数据文件时.

when adding binary and data files.

我已经尝试了互联网上几乎所有的解决方案

I've tried almost every single solution on the internet

推荐答案

将hook-nltk.py文件更改为此

Change hook-nltk.py file to this

import os
import nltk
from PyInstaller.utils.hooks import collect_data_files
# add datas for nltk
datas = collect_data_files('nltk', False)

# loop through the data directories and add them
for p in nltk.data.path:
    if os.path.exists(p):
        datas.append((p, "nltk_data"))

# nltk.chunk.named_entity should be included
hiddenimports = ["nltk.chunk.named_entity"]

和 更改将文件"pyi_rth_nltk.py"而不是"pyi_rth__nltk.py"的双精度空格删除.该文件可以位于\ Anaconda3 \ Lib \ site-packages \ PyInstaller \ loader \ rthooks

and change remove the double space to single space of file "pyi_rth_nltk.py" instead of "pyi_rth__nltk.py".This file can be at \Anaconda3\Lib\site-packages\PyInstaller\loader\rthooks

这篇关于nltk-hook无法找到nltk_data的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆