New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to add a hook for textblob in pyinstaller #185
Comments
Looks very similar to #134. |
I suspect pyinstaller is not bundling the required data files. For polarity (sentiment), the code doesn't complain if if not path:
path = self._path
if not os.path.exists(path):
return I'm not a pyinstaller expert, but looking at the docs it looks like you can specify additional files by modifying Here is a list of data files: ./textblob/en/en-entities.txt
./textblob/en/en-spelling.txt
./textblob/en/en-morphology.txt
./textblob/en/en-context.txt
./textblob/en/en-lexicon.txt
./textblob/en/en-sentiment.xml For your use case, only added_files = [
( 'textblob/en/*.txt', 'textblob/en' ),
( 'textblob/en/*.xml', 'textblob/en' ),
]
a = Analysis(...
datas = added_files,
...
) Can you give that a try? If that's the issue, I'll look at a PR that raises a useful error. |
@jschnurr thank you i'll try it |
Hope Jeff's suggestion worked out. Closing this for now. |
i added the commands in .spec and i get an error |
I have done just this and even checked if the files were copied over into the exe directory and they were. Yet I'm still getting 0s when running the exe. I'm running python 3.7.3 and had to change the source code for pyinstaller to get the nltk import to work. Do you think the issue may have come from this. |
I had the same issue and adding those files in the correct path worked for me. Make sure the files get copied to INSTALL_PATH=$(pip3 show textblob | grep Location)
pyinstaller \
--add-data ${INSTALL_PATH:10}/textblob/en/en-entities.txt:textblob/en \
--add-data ${INSTALL_PATH:10}/textblob/en/en-morphology.txt:textblob/en \
--add-data ${INSTALL_PATH:10}/textblob/en/en-spelling.txt:textblob/en \
--add-data ${INSTALL_PATH:10}/textblob/en/en-context.txt:textblob/en \
--add-data ${INSTALL_PATH:10}/textblob/en/en-lexicon.txt:textblob/en \
--add-data ${INSTALL_PATH:10}/textblob/en/en-sentiment.xml:textblob/en \
<your python file>.py I Hope this helps |
when i create a .exe file using pyinstaller and execute it it is not fetching any result from
`b = TextBlob(ar)
score = b.sentiment.polarity`
it returns proper value when executed on console but return 0 when executed with .exe
your help will be really appreciated .
thank you
The text was updated successfully, but these errors were encountered: