如何使用pyInstaller完全打包所有必需的库? [英] How to use pyInstaller to completely pack all the necessary Library?

查看:21
本文介绍了如何使用pyInstaller完全打包所有必需的库?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经使用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

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

我认为是nltk或textblob,有谁能帮助将这些文件添加到包中吗?

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

推荐答案

您可以将nltk_data文件夹从nltk下载的位置复制到您的应用程序目录。在需要库的脚本中,使用上面的建议:

basedir = os.path.abspath(os.path.dirname(__file__))
import nltk
nltk.data.path.append(basedir + 'nltk_data')

然后使用

构建pyinstaller文件
pyinstaller -F --add-data "nltk_data;nltk_data" app.py

这篇关于如何使用pyInstaller完全打包所有必需的库?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆