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
Distributable .exe that imports WordCloud fails because of missing file #381
Comments
There is a file called stopwords in wordcloud that it reads It seems pyinstaller doesn't bundle that correctly. A simple but hacky way to work around this would be to include the stopwords in the py file. |
That's correct, it doesn't bundle that. The question for me however is: Why does wordcloud require this file, if I use my own precompiled words? from wordcloud import WordCloud tuples = ... # my own list of (wordfreq, word)-tuples It doesn't need the stopwords. It seems to me from the source code that STOPWORDS is being read anyways, regardless of whether they are being used or not. A better solution, to my mind, would be to only load the STOPWORDS file if they are actually being used. I can write a PR on that, if you agree. |
Yes, loading in init seems fine. Though you might still have issues with the font unless you use a different one. |
PR is live. We can do the same with the font if you deem it relevant. On my distributable I had no problems with the font but loading the fontfile only when needed seems safer. |
The font is only loaded when it's needed. |
Here's instructions on how you have to use pyinstaller: https://pyinstaller.readthedocs.io/en/v3.3.1/spec-files.html#adding-files-to-the-bundle |
find the stopwords file in folder env\lib\site-packages\wordcloud\ |
I am not familiar with spec file. What do you mean "You can edit the spec file of your python script,as below: |
@philip928lin I linked it above. |
a good fix given here https://www.programmersought.com/article/5635871566/ |
Hi, Do you know how to handle it? :) |
It looks like there's some issue with the font path. If not, I would check with pyinstaller, as this is a pyinstaller usage issue. |
Description
I compiled a python3.5 script that includes WordCloud using pyinstaller on Windows 10 in order to have a distributable exe file. The exe fails because it is looking for a file stopwords in folder Wordcloud in the user's temp directory. The script runs all fine when exectued in script or bash mode. The file is being looked up in a folder with cryptic name, which changes on every run. The foldername always starts with _MEI followed by some numbers.
Steps/Code to Reproduce
Compile python script on windows with pyinstaller and include line ``from wordcloud import WordCloud`
Error message
I think this behaviour is not intended. It is related to wordcloud or might it be caused by pyinstaller?
The text was updated successfully, but these errors were encountered: