When using pyinstaller to build an executable I get
unable to find /home/usr/nltk_data
when adding binary and data files.
I've tried almost every single solution on the internet
When using pyinstaller to build an executable I get
unable to find /home/usr/nltk_data
when adding binary and data files.
I've tried almost every single solution on the internet
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"]
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
I solved the problems editing the pyinstaller nltk-hook (inside python3). After much research, I decided to go it alone in the code structure. I solved my problem by commenting on the lines:
datas=[]
'''for p in nltk.data.path:
datas.append((p, "nltk_data"))'''
hiddenimports = ["nltk.chunk.named_entity"]
What's more, you need to rename the file: pyi_rth__nltk.cpython-36.pyc to pyi_rth_nltk.cpython-36.pyc This file have 1 more underline. Warning with the python version.