[英]Pyinstaller exe failed to execute script
So this is my code, I can run it on my computer. 这是我的代码,我可以在计算机上运行它。 As soon as I move it to another computer via flash drive, and try and open it, it reads failed to execute script.
一旦我将其通过闪存驱动器移至另一台计算机并尝试将其打开,它就会读取无法执行脚本的信息。 I used Pyinstaller with the commands for -w -F -i.
我将Pyinstaller与-w -F -i命令一起使用。
I've tried on two other computers aside from my own, it works on mine, but not on others. 除了我自己的计算机外,我还尝试了另外两台计算机,该计算机可以在我的计算机上运行,但不能在其他计算机上运行。 Please help!
请帮忙!
from wand.image import Image as wand_image
import re
import os
import Tkinter as Tk
from ttk import *
import tkMessageBox
from datetime import datetime
import threading
total_files= 0
files_finished= 0
root = Tk.Tk() #Starts the GUI.
root.resizable(False, False)
canvas= Tk.Canvas(root)
canvas.pack(fill=Tk.BOTH, expand=1)
canvas.config(width=500, height=125)
canvas.create_rectangle(0,0,500,500, fill="blue")
canvas.grid(row=0, rowspan=30, columnspan=100)
current_update= Tk.Label(root, text="... Activity Feed...", font="-weight bold", background ="cyan", width=49, height=2, border=0)
current_update.grid(row=4, column=0, columnspan=100)
current_update_display= Tk.Label(root, font="-weight bold", background ="black", foreground="white", width=49, height=2 , relief= "sunken", \
text="0 out of 0 files completed.")
current_update_display.grid(row=5, column=0, columnspan=100, sticky="N")
Progressbar= Progressbar(length=495, maximum=0)
Progressbar.grid(row=6, rowspan=30, columnspan=100)
def get_total():
global total_files
for folder in os.listdir(os.getcwd()):
if not os.path.isdir(folder) or re.search('zzz-Files Without Dates-zzz', folder):
continue
for filename in os.listdir(folder):
file_type= re.search(r"\.\w+", filename)
if file_type==None:
continue
else:
file_type= file_type.group()
new_filename= "%s%s" % (re.sub(".pdf", "", filename), " -converted_page.png")
if not re.search(".pdf", filename) or re.search(" -converted_page.png", filename) or os.path.exists(r"%s\%s" % (folder, new_filename)):
continue
elif re.match(r"%s \d{6}%s" % (folder, file_type), filename) or re.match(r"%s \d{6} \(\d+\)%s" % (folder, file_type), filename):
try:
possible_date_code= re.search(r"\d{6}", filename).group()
possible_date= datetime(month=int(possible_date_code[:2]), day=int(possible_date_code[2:4]), year=int(possible_date_code[4:])+2000)
if possible_date<datetime.now():
continue
except ValueError:
pass
total_files+=1
Progressbar.config(maximum=total_files)
current_update_display.config(text="%s out of %s files finised." % ("0", total_files))
def convert():
global total_files, files_finished
for folder in os.listdir(os.getcwd()):
if not os.path.isdir(folder) or re.search('zzz-Files Without Dates-zzz', folder):
continue
for filename in os.listdir(folder):
file_type= re.search(r"\.\w+", filename)
if file_type==None:
continue
else:
file_type= file_type.group()
new_filename= "%s%s" % (re.sub(".pdf", "", filename), " -converted_page.png")
if not re.search(".pdf", filename) or re.search(" -converted_page.png", filename) or os.path.exists(r"%s\%s" % (folder, new_filename)):
continue
elif re.match(r"%s \d{6}%s" % (folder, file_type), filename) or re.match(r"%s \d{6} \(\d+\)%s" % (folder, file_type), filename):
try:
possible_date_code= re.search(r"\d{6}", filename).group()
possible_date= datetime(month=int(possible_date_code[:2]), day=int(possible_date_code[2:4]), year=int(possible_date_code[4:])+2000)
if possible_date<datetime.now():
continue
except ValueError:
pass
with wand_image(filename=r"%s\%s" % (folder, filename),resolution=300) as source:
images=source.sequence
wand_image(images[0]).save(filename=r"%s\%s" % (folder, new_filename))
files_finished+=1
current_update_display.config(text="%s out of %s files finised." % (files_finished, total_files))
Progressbar.step(1)
root.destroy()
for interval in range(2):
if interval==0:
thread_object= threading.Thread(target=get_total)
else:
thread_object= threading.Thread(target=convert)
thread_object.daemon = True
thread_object.start()
root.mainloop()
These are general things you might or might not have thought about: 这些是您可能会或可能不会考虑的常规事项:
Pyinstaller need to have the same type of system to deploy to as the system you are building on. Pyinstaller需要与要构建的系统具有相同类型的系统。 If you are building on a 64 bit platform then you can deploy to a 64 bit platform.
如果您在64位平台上构建,则可以部署到64位平台。 A 32 bit platform build will deploy to 32 bit platforms.
32位平台版本将部署到32位平台。
So you have path statements that are to the libraries on your computer but those don't exist then you have to bring them with you in the spec file . 因此,您具有指向计算机上库的路径语句,但是这些路径语句不存在,那么您必须将它们随同带到spec文件中 。
I would suggest doing a one directory install rather than a file install for the first attempt, it's slightly easier. 我建议第一次尝试执行一个目录安装而不是文件安装,这稍微容易一些。
Alright well I ran pyinstaller without -w so the command prompt would still open. 好吧,我在没有-w的情况下运行pyinstaller,因此命令提示符仍将打开。
I ran it and got 我跑了
ImportError: MagickWand shared library not found.
You probably had not installed ImageMagick library.
So for whatever reason it still requires that even after it was made into a exe. 因此,无论出于何种原因,即使将其制作成exe文件,它仍然需要。 So the new device needs it as well, odd but oh well.
因此,新设备也需要它,奇怪但很好。
This is now a new issue so I'll move on from here, but now I know. 现在这是一个新问题,因此我将从这里继续,但是现在我知道了。 Thanks to everyone who read and commented!
感谢所有阅读和评论的人!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.