Question: I am trying to create executable python file using pyinstaller, but while loading hooks, it shows error like this,

```
24021 INFO:   Removing import of PySide from module PIL.ImageQt
24021 INFO: Loading module hook "hook-pytz.py"...
24506 INFO: Loading module hook "hook-encodings.py"...
24600 INFO: Loading module hook "hook-pandas.py"...
25037 INFO: Loading module hook "hook-lib2to3.py"...
25131 INFO: Loading module hook "hook-lxml.etree.py"...
25131 INFO: Loading module hook "hook-pycparser.py"...
25396 INFO: Loading module hook "hook-setuptools.py"...
25506 WARNING: Hidden import "setuptools.msvc" not found!
25506 INFO: Loading module hook "hook-distutils.py"...
25521 INFO: Loading module hook "hook-nltk.py"...
Unable to find "C:\nltk_data" when adding binary and data files.

```

I have tried coping nltk\_data from Appdata to C drive. but same error.

Answer: 
I have been working on this issue for a few days not and don't have hair left. For some reason nltk and pyinstaller do not work well together. 

So my first solution to this issue is to use something other than nltk if it is possible to code the solution without nltk.

If you must use NLTK, I solved this by forcing the nltk\_data path into datas.

1. Locate your nltk\_data path. Mine was in
C:\Users\user-name\AppData\Roaming\nltk\_data
2. In hook-nltk.py (within pyinstaller directory) I commented out and added lines to look like this.

```
    import nltk
    from PyInstaller.utils.hooks import collect_data_files

    datas = collect_data_files('nltk', False)
    '''
    for p in nltk.data.path:
        datas.append((p, "nltk_data"))
    '''
    datas.append(("C:\\Users\\nedhu\\AppData\\Roaming\\nltk_data", "nltk_data"))

    hiddenimports = ["nltk.chunk.named_entity"]

```

There is a deeper problem with pyinstaller looping through the datas list of paths, but this solution works as a patch.
I solved the problems editing the pyinstaller nltk-hook. 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.