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

Pyinstaller hook for gensim package #362

Open
RajiRai opened this issue May 24, 2019 · 2 comments
Open

Pyinstaller hook for gensim package #362

RajiRai opened this issue May 24, 2019 · 2 comments

Comments

@RajiRai
Copy link

RajiRai commented May 24, 2019

Hi
I have a python script to summarize text using Python's gensim package. I wanted to create a exe for this script. When I compiled this script using Pyinstaller, the exe was created but it is not opening and throwing fatal error. I commented the gensim import and compiled, the exe file opened successfully. So due to lack of hook for gensim, I presume the exe is throwing error.

Below is my code:

*from gensim.summarization import summarize
from tkinter import *
import tkinter
from tkinter import messagebox
top = Tk()

def process():
sentence=Entry.get(E1)
ans=summarize(sentence)
Entry.insert(E4,0,ans)
print(ans)

top.title("Text Summarizer")
L1 = Label(top, text="Text Summarizer",).grid(row=0,column=1)
L2 = Label(top, text="Enter text to summerize",).grid(row=1,column=0)
L3 = Label(top, text="Answer",).grid(row=4,column=0)
E1 = Entry(top, bd=5)
E1.grid(row=1, column=1)
E4 = Entry(top, bd =5)
E4.grid(row=4,column=1)
B=Button(top, text ="Submit",command = process).grid(row=5,column=1,)

top.mainloop()*

I searched for solution but found none hence requesting help on this.

Thanks
Raji

@balaa
Copy link

balaa commented Jun 13, 2019

you can create a hook file with name hook-gensim.py under venv/lib/python3.7/site-packages/PyInstaller/hooks folder ( assuming venv is you virtual environment folder name & python 3.7 as as your python version). the following is the hook file i have used for my application. this is not the best solution but its a working solution for me.

from PyInstaller.utils.hooks import collect_submodules, collect_data_files

# This collects all dynamically imported gensim modules and data files.
hiddenimports = (collect_submodules('gensim') + collect_submodules('gensim.models')+
                 collect_submodules('gensim.corpora')+ collect_submodules('gensim.sklearn_api')+
                 collect_submodules('gensim.summarization') + collect_submodules('gensim.parsing')+
collect_submodules('gensim.topic_coherence')+collect_submodules('gensim.scripts')+collect_submodules('gensim.viz')+
                 collect_submodules('gensim.similarities')+collect_submodules('gensim.test')


)
datas = (collect_data_files('gensim') + collect_data_files('gensim.models')+
                 collect_data_files('gensim.corpora')+ collect_data_files('gensim.sklearn_api')+
                 collect_data_files('gensim.summarization') + collect_data_files('gensim.parsing')+
collect_data_files('gensim.topic_coherence')+collect_data_files('gensim.scripts')+collect_data_files('gensim.viz')+
                 collect_data_files('gensim.similarities')+collect_data_files('gensim.test')

)

@RajiRai
Copy link
Author

RajiRai commented Jun 13, 2019 via email

@bwoodsend bwoodsend transferred this issue from pyinstaller/pyinstaller Dec 22, 2021
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

2 participants