Open JustinLin905 opened 3 years ago
I never tried to make it usable from a stand-alone executable, but it would be a good feature. It seems that it's a problem with dictionary data that autocorrect needs, but pyinstaller cannot automatically bundle.
Autocorrect looks for a file data/{lang}.tar.gz
and if it doesn't exist it will try to download it: https://github.com/fsondej/autocorrect/blob/bda610212a77a193df5b5defe5c7f79a10f1e5e1/autocorrect/__init__.py#L34
First, you can try to make a directory data
and put there en.tar.gz
downloaded from that URL. This data
directory should be in the same directory as your executable.
If that works you can try to bundle that file, so you won't need additional directory. You can do it with pyinstaller's --add-data
option https://stackoverflow.com/questions/41870727/pyinstaller-adding-data-files
Thanks for your response! Unfortunately, making a data
directory with en.tar.gz
inside did not fix the crash. My program still attempts to download the dictionary data.
Hopefully a stand-alone .exe with autocorrect will be possible sometime in the future!
Hmm, it looks that finding location works differently in stand-alone exe than in python file. We could add option in Speller.__init__
to give dictionary location manually https://github.com/fsondej/autocorrect/blob/bda610212a77a193df5b5defe5c7f79a10f1e5e1/autocorrect/__init__.py#L73
and later bundle those files using pyinstaller's --add-data
option.
Unfortunately, I don't have time to do this now, but this should work.
Any update on this?
Wouldn't the crash come from broken links to the "backup_urls" files?
There is currently an issue which causes .exe files created using pyinstaller to crash.
If the source Python file used the autocorrect library, the program would crash if the user tried to launch it from the .exe file. "dictionary for this language not found, downloading..." will appear in the terminal, then "couldn't download https://drive.google.com/uc?export=download&id=19xqFyk9d8aFR7LR43oy6cExk8Pk9wVwV, trying next url...", followed by a ConnectionError: [Errno 2]. When I visit the link in my browser, it seems to work. This is for the English language.
Is it possible to fix this, or is the library not meant to be used from a stand-alone executable?