如何使用pyInstaller完整打包所有必需的库?

2024-01-04

我已经使用 pyinstaller 创建了我的 python 应用程序的独立应用程序

pyinstaller --windowed app.py

它实际上在我的计算机上运行并且按预期工作,但是当我在我朋友的计算机上尝试它时,它不起作用。它运行但不知何故无法处理文本。

这是使用的库:

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

如果你想查看结果文件:https://www.dropbox.com/s/mfdnaaoik7w0r23/TextSummaryV73.rar?dl=0 https://www.dropbox.com/s/mfdnaaoik7w0r23/TextSummaryV73.rar?dl=0

有人知道出了什么问题或缺少什么吗?

我认为它是 nltk 或 textblob,任何人都可以帮助如何将这些文件添加到包中吗?

EDIT:我已使用规范文件将 nltk 和 textblob 添加到 Python 应用程序的目录中。现在的问题是,如何让程序知道这两个导入已经在目录中了?


我相信您正在寻找的命令是 --onefile。这会将所有必需的包打包到可执行文件中。本指南 https://mborgerson.com/creating-an-executable-from-a-python-script应该对你有帮助。

pyinstaller --onefile --windowed app.py

如果您有脚本所需的任何外部文件,这会使该过程变得更加困难,因为您需要更改对其位置的引用。这个答案 https://stackoverflow.com/questions/7674790/bundling-data-files-with-pyinstaller-onefile or this one https://stackoverflow.com/questions/19669640/bundling-data-files-with-pyinstaller-2-1-and-meipass-error-onefile可以帮忙

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

如何使用pyInstaller完整打包所有必需的库? 的相关文章

随机推荐