Skip to content
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

Crash when using autocorrect library from pyinstaller .exe file #19

Open
JustinLin905 opened this issue Dec 30, 2020 · 5 comments
Open

Comments

@JustinLin905
Copy link

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?

@filyp
Copy link
Owner

filyp commented Dec 31, 2020

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

@JustinLin905
Copy link
Author

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!

@filyp
Copy link
Owner

filyp commented Jan 3, 2021

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.

@JoshSilver8
Copy link

Any update on this?

@David-Baron
Copy link

Wouldn't the crash come from broken links to the "backup_urls" files?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants