我使用python 3编写了一个桌面应用程序,这是一个API数据收集应用程序。当我创建可执行文件(.exe)时,它可以在我的计算机上完美运行,但是当我在其他计算机上打开它时,会出现Failed to execute script消息。
代码我仅导入以下内容。
from tkinter import*
import requests
import json
然后我按如下所示添加了API。
try:
#Connect the API to the .py code
api_data=requests.get("https://www.hpb.health.gov.lk/api/get-current-statistical")
api_json=json.loads(api_data.content)
#Connect with variables
lu_date= api_json['data']['update_date_time']
lu_cases= api_json['data']['local_new_cases']
lu_total= api_json['data']['local_total_cases']
lu_hospital= api_json['data']['local_total_number_of_individuals_in_hospitals']
lu_deaths= api_json['data']['local_deaths']
lu_recover= api_json['data']['local_recovered']
lu_rate1=int((lu_deaths/lu_recover)*100)
#Added some labels here
#Button
ext_btn=Button(root, text="Exit", command=root.destroy,bg="red",fg="white",font="Helvatica 12 bold",padx=25)
ext_btn.grid(row=8,column=0,columnspan=2)
out = out.decode(encoding)
except Exception as e:
api_json="Error"
root.mainloop()
我已经尝试过以下方法来执行它,但是它不起作用。 (通过使用命令行以及给定的GUI软件)
pyinstaller -F codename.py
经过大量研究和指示,我可以找到问题。谢谢@Bryan Oakley的指导。问题