I have already used pyinstaller to create a standalone aplication of my python aplication
pyinstaller --windowed app.py
and it actually run in my computer and work just as intended, but when I tried it on my friend's computer, it didn't work. It runs but somehow it can't process the text.
here are the library used:
import tkinter as Tk
import tkinter.ttk as ttk
import tkinter.scrolledtext as ScrollTxt
from tkinter import END,E,W,filedialog,messagebox
from nltk.tokenize import sent_tokenize, RegexpTokenizer, word_tokenize
import math
import fileinput
from textblob import TextBlob as tb
from nltk.tag import pos_tag, map_tag
from nltk.corpus import stopwords
if you want to see the result file: https://www.dropbox.com/s/mfdnaaoik7w0r23/TextSummaryV73.rar?dl=0
anybody knows what's wrong or what's missing?
I think it's either nltk or textblob, can anyone help how to add these files into the package?
EDIT: I have added nltk and textblob into the Python Application's directory using spec files. now the problem is, how to make the program know that these two imports are already inside the directory?
You can copy the nltk_data folder from where it is downloaded by nltk to your app directory. In your script where you require the library use Sandeep's suggestion with:
basedir = os.path.abspath(os.path.dirname(__file__))
import nltk
nltk.data.path.append(basedir + 'nltk_data')
Then build your pyinstaller file with
pyinstaller -F --add-data "nltk_data;nltk_data" app.py
I believe the command you are looking for is --onefile. This packages all required packages into the executable. This guide should help you.
pyinstaller --onefile --windowed app.py
If you have any external files that are required by the script this makes the process a bit more difficult as you will need to change your references to their location. This answer or this one can help with that
I faced the same issue and I was able to solve it as shown:
Copy the 'nltk data' contents that you are using into a nltk_data_folder
Write these two lines in the python code:
{
import nltk
nltk.data.path.append(r'nltk_data_folder')
}
place nltk_data_folder in the 'Application_folder' where the .exe file is present
You can now copy this 'Application_folder' (containing nltk_data_folder, .exe file and other supporting files) on any other PC and run the .exe file.
Hope this helps!!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With