![](/img/trans.png)
[英]Pyinstaller "Failed to execute script due to unhandled exception" Error
[英]Pyinstaller exe file failed to execute script due to unhandled exception
我试图使用命令 pysintaller --onefile [name] 将我的 python 程序转换为 .exe 文件,一切正常,但是当我运行 my.exe 文件时,我收到错误“由于未处理的异常而无法执行脚本,否模块名称请求。我已经安装了库并将我的文件夹移出 dist 文件,但同样的事情。有人可以帮我吗?(我用 Visual Studio 测试了我的代码,它可以工作。
import requests
import tkinter
from cProfile import label
from tkinter import *
from bs4 import BeautifulSoup
def show_data():
link = ent.get()
result = requests.get(link)
soup = BeautifulSoup(result.text, 'html.parser')
images = soup.find_all('img')
liste = []
for image in images:
image = image['src']
if "https://cdn2.sorsware.com" and "buyuk" in image:
liste.append(image)
txt.insert(0.0,liste)
def delete_data():
txt.delete(1.0,END)
gui = Tk()
gui.geometry("1000x500")
gui.title("BSL")
l1 = Label(gui,text="Link:")
ent = Entry(gui,width=600)
l1.grid(row=0)
ent.grid(row=0,column=1)
txt = Text(gui,width=125,wrap=WORD,font=("Arial",10))
txt.place(x=500,y=250,anchor=CENTER)
btn = Button(gui,text = "Results",bg ="black",fg="white",width=5,height=2,command=show_data)
btn.grid(row=1)
btn_delete = Button(gui,text = "delete",bg ="black",fg="white",width=5,height=2,command=delete_data)
btn_delete.grid(row=2)
gui.mainloop()
看起来它找不到requests
模块。 确保您在安装了所有依赖项的虚拟环境中运行pyinstaller
。
你可以安装
pip install requests
pip 安装请求一旦我几天前也遇到同样的错误,请尝试此命令
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.