Search code examples
hookpyinstallertextblob

How to add a hook for textblob in pyinstaller


I am trying to 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

def start_dmo():
 print ("Importing all the required packages...")
 from textblob import TextBlob
 input ("press enter to continue")
 print("All Necessary Packages imported")
 input("press enter to continue")
 ar="I cant be more happy with this"
 print(ar)
 b = TextBlob (ar)
 score = b.sentiment.polarity
 print (b.sentiment.polarity)
 input("press enter to continue")
 score = round (score, 2)
 if score > 0.0:
    senti = "Positive"
elif score < 0.0:
    senti = "Negative"
else:
    senti = "Neutral"
 print("Score"+str(score)+"sentiment"+senti)
 input("press enter to continue")

start_dmo()

this is the output when the above code is executed on console

this is the output when the above code is executed on .exe of the same code which is created using pyinstaller


Solution

  • Issue Solved! Simple Solution Changed pyinstaller to cx_Freeze FYI cx_Freeze works perfectly fine with python 3.6 to know how to create .exe using cx_freeze follow the below link: https://pythonprogramming.net/converting-python-scripts-exe-executables/

    if u use numpy or pandas u might need to add option cz it might not import numpy to form ur exe so solve that issue follow below link: Creating cx_Freeze exe with Numpy for Python

    Good luck!