[GH-ISSUE #29] Fatal Error! - Failed to execute the script #28

Closed
opened 2026-02-26 12:20:14 +03:00 by kerem · 6 comments
Owner

Originally created by @Pechi77 on GitHub (Nov 10, 2018).
Original GitHub issue: https://github.com/brentvollebregt/auto-py-to-exe/issues/29

Hi, I created a tkinter application and tried converting it to exe using auto-py-to-exe.
when I run the exe I get Fatal Error! - Failed to execute the script

please help.

My code:

`import os
import tkinter
from tkinter import messagebox
from tkinter import filedialog
from tkinter import *
import time
import sys
import pandas as pd
from bs4 import BeautifulSoup
from selenium import webdriver
import win32com.client as win32
import time
import numpy as np
import traceback
import datetime
def config():
return datetime.date.today() < datetime.date(2018,11,16)

#b=tkinter.Tk()

def send_email(to_addr,subject,carrier_name,vr_id,trailer):

#print(mail.Body)
#mail.HTMLBody = '<h2>HTML Message body</h2>' #this field is optional

# To attach a file to the email (optional):
#attachment  = "Path to the attachment"
#mail.Attachments.Add(attachment)
mail.Send()

def process(fc_value,file_addr):
try:
carrier_df=pd.read_excel(file_addr)
#drop_down_value=str(sys.argv[1])
url= 'https://mysite.com'

    #drop_down_value=''
    driver=webdriver.Chrome()
    driver.get(url)
    time.sleep(2)
    driver.find_element_by_xpath(f"//select[@id='availableNodeName']/option[text()='{drop_down_value}']").click()
    #driver.find_element_by_xpath("""//select[@id="availableNodeName"]/option[text()='MSP1']""").click()
    time.sleep(2)
    soup=BeautifulSoup(driver.page_source,'html.parser')
    #print(soup)
    no_of_pages=int(soup.find(class_='paginate_of').find('strong').text)

    df_list=[]

    for i in range(1,no_of_pages):
        df=pd.read_html(driver.page_source)
        df=df[5]
        df_list.append(df)
        #print(df)
        next_button=driver.find_elements_by_xpath('//a[@class="next nxt fg-button ui-button ui-state-default"]')
        if next_button:
            next_button[0].click()
            time.sleep(2)
    driver.close()
    main_df=pd.concat(df_list)
    main_df['Status']=main_df['Status'].fillna('n/a')
    main_df['Status']=main_df['Status'].astype(str)
    main_df=main_df[main_df['Status'].str.contains('Finished Loading')]
    #main_df.to_excel('test_data.xlsx',index=False)

    #pre-processing dataframes to proceed
    carrier_df['SCAC']=carrier_df['SCAC'].str.strip('[]')
    main_df['Carrier']=main_df['Carrier'].apply(lambda x: x.split('[')[0])

    #filter only matching email on both df
    columns_needed=['Sort/Rodfdfute','Locatdfdfion','VdfdfR Id','Cdfdfdfddfdfdfdfdfdarrier','Tradfddfiler']
    main_df=main_df[columns_needed]

    main_df['Carrier']=main_df['Carrdfdfier'].str.strip()
    carrier_df['SCAC']=carrier_df['dfd'].str.strip()
    final_df=main_df[main_df['Cadfdfrrier'].isin(carrier_df['dfdfdfdf'])]
    final_df.loc[:,'email']=final_df['Carriedfdfddr'].map(dict(zip(carrier_df['dfdfdf'],carrier_df['Email Address'])))

    #Handling multiple email id's
    final_df[columns_needed]=np.repeat(final_df[columns_needed].values,(final_df['email'].str.split(',').str.len()),axis=0)
    final_df['email']=','.join(final_df['email'].values.flatten()).split()
    #removing tick mark in trailer column
    final_df['Trailer']=final_df['Trailer'].str[:-2]
    for to_addr, vr_id, trailer,carrier in zip(final_df['email'],final_df['VR Id'],final_df['Trailer'],final_df['Carrier']):
         send_email(to_addr=to_addr,subject='pull',carrier_name=carrier,mjj=vr_id,trailer=njj)
    return 'completed'
except Exception:
    status=traceback.format_exc()
    return status

print('completed')

a=tkinter.Tk()

a.geometry("500x600+500+100")
a.title('Early pull Application by ROC')

def set_value(text):
fc_value=text_textbox1.get()
file_addr=text_textbox2.get()
status='processing'
if config():
status=process(fc_value,file_addr)
my_label2.config(text=status)

def fileopen():
file1=filedialog.askopenfile()
file1=file1.name
text_textbox2.set(str(file1))

#defining objects
my_label2=tkinter.Label(a,text="Facility Code ex - ONT8",fg="green",bg="white",font=("aerial",10,"italic"))
text_textbox1=tkinter.StringVar()
text_textbox2=tkinter.StringVar()
my_msgbox=tkinter.Entry(a,textvariable=text_textbox1)

my_button=tkinter.Button(a,text='Go ',command=lambda : set_value('dfdf'))
txt_label=tkinter.Entry(a,textvariable=text_textbox2,width=38)

btn_browse=tkinter.Button(a,text="Browse",fg="red",bg="white",command=fileopen)

#placing objects
btn_browse.place(x=300,y=200)
txt_label.place(x=43,y=200)
my_label2.place(x=15,y=100)
my_msgbox.place(x=45,y=130)
my_button.place(x=220,y=120)
a.mainloop()
`

Originally created by @Pechi77 on GitHub (Nov 10, 2018). Original GitHub issue: https://github.com/brentvollebregt/auto-py-to-exe/issues/29 Hi, I created a tkinter application and tried converting it to exe using `auto-py-to-exe`. when I run the exe I get `Fatal Error! - Failed to execute the script` please help. My code: `import os import tkinter from tkinter import messagebox from tkinter import filedialog from tkinter import * import time import sys import pandas as pd from bs4 import BeautifulSoup from selenium import webdriver import win32com.client as win32 import time import numpy as np import traceback import datetime def config(): return datetime.date.today() < datetime.date(2018,11,16) #b=tkinter.Tk() def send_email(to_addr,subject,carrier_name,vr_id,trailer): #print(mail.Body) #mail.HTMLBody = '<h2>HTML Message body</h2>' #this field is optional # To attach a file to the email (optional): #attachment = "Path to the attachment" #mail.Attachments.Add(attachment) mail.Send() def process(fc_value,file_addr): try: carrier_df=pd.read_excel(file_addr) #drop_down_value=str(sys.argv[1]) url= 'https://mysite.com' #drop_down_value='' driver=webdriver.Chrome() driver.get(url) time.sleep(2) driver.find_element_by_xpath(f"//select[@id='availableNodeName']/option[text()='{drop_down_value}']").click() #driver.find_element_by_xpath("""//select[@id="availableNodeName"]/option[text()='MSP1']""").click() time.sleep(2) soup=BeautifulSoup(driver.page_source,'html.parser') #print(soup) no_of_pages=int(soup.find(class_='paginate_of').find('strong').text) df_list=[] for i in range(1,no_of_pages): df=pd.read_html(driver.page_source) df=df[5] df_list.append(df) #print(df) next_button=driver.find_elements_by_xpath('//a[@class="next nxt fg-button ui-button ui-state-default"]') if next_button: next_button[0].click() time.sleep(2) driver.close() main_df=pd.concat(df_list) main_df['Status']=main_df['Status'].fillna('n/a') main_df['Status']=main_df['Status'].astype(str) main_df=main_df[main_df['Status'].str.contains('Finished Loading')] #main_df.to_excel('test_data.xlsx',index=False) #pre-processing dataframes to proceed carrier_df['SCAC']=carrier_df['SCAC'].str.strip('[]') main_df['Carrier']=main_df['Carrier'].apply(lambda x: x.split('[')[0]) #filter only matching email on both df columns_needed=['Sort/Rodfdfute','Locatdfdfion','VdfdfR Id','Cdfdfdfddfdfdfdfdfdarrier','Tradfddfiler'] main_df=main_df[columns_needed] main_df['Carrier']=main_df['Carrdfdfier'].str.strip() carrier_df['SCAC']=carrier_df['dfd'].str.strip() final_df=main_df[main_df['Cadfdfrrier'].isin(carrier_df['dfdfdfdf'])] final_df.loc[:,'email']=final_df['Carriedfdfddr'].map(dict(zip(carrier_df['dfdfdf'],carrier_df['Email Address']))) #Handling multiple email id's final_df[columns_needed]=np.repeat(final_df[columns_needed].values,(final_df['email'].str.split(',').str.len()),axis=0) final_df['email']=','.join(final_df['email'].values.flatten()).split() #removing tick mark in trailer column final_df['Trailer']=final_df['Trailer'].str[:-2] for to_addr, vr_id, trailer,carrier in zip(final_df['email'],final_df['VR Id'],final_df['Trailer'],final_df['Carrier']): send_email(to_addr=to_addr,subject='pull',carrier_name=carrier,mjj=vr_id,trailer=njj) return 'completed' except Exception: status=traceback.format_exc() return status print('completed') a=tkinter.Tk() a.geometry("500x600+500+100") a.title('Early pull Application by ROC') def set_value(text): fc_value=text_textbox1.get() file_addr=text_textbox2.get() status='processing' if config(): status=process(fc_value,file_addr) my_label2.config(text=status) def fileopen(): file1=filedialog.askopenfile() file1=file1.name text_textbox2.set(str(file1)) #defining objects my_label2=tkinter.Label(a,text="Facility Code ex - ONT8",fg="green",bg="white",font=("aerial",10,"italic")) text_textbox1=tkinter.StringVar() text_textbox2=tkinter.StringVar() my_msgbox=tkinter.Entry(a,textvariable=text_textbox1) my_button=tkinter.Button(a,text='Go ',command=lambda : set_value('dfdf')) txt_label=tkinter.Entry(a,textvariable=text_textbox2,width=38) btn_browse=tkinter.Button(a,text="Browse",fg="red",bg="white",command=fileopen) #placing objects btn_browse.place(x=300,y=200) txt_label.place(x=43,y=200) my_label2.place(x=15,y=100) my_msgbox.place(x=45,y=130) my_button.place(x=220,y=120) a.mainloop() `
kerem closed this issue 2026-02-26 12:20:14 +03:00
Author
Owner

@brentvollebregt commented on GitHub (Nov 10, 2018):

Most of the time this is not an issue with auto-py-to-exe or PyInstaller but incorrect configuration (which is ok). This means you will then need to enable debugging for the project to investigate the issue and hold on to any output.

To enable debugging, go into the "Advanced" section and under the title "How to generate" put 'all' in the box beside --debug. This will print out messages to the console to help you debug.

When debugging, make sure you selected the "Console Based" button and using "One Directory" will help remove basic problems; you can switch back to "One File" when there are no more bugs and then fix the ones associated with "One File".

After re-packaging your project, open up cmd, use the cd command to change directories to where the exe is located and then execute ./my_project.exe (substitute the names). This will run the executable and any errors you were missing before will be output to the console.

<!-- gh-comment-id:437601370 --> @brentvollebregt commented on GitHub (Nov 10, 2018): Most of the time this is not an issue with auto-py-to-exe or PyInstaller but incorrect configuration (which is ok). This means you will then need to enable debugging for the project to investigate the issue and hold on to any output. To enable debugging, go into the "Advanced" section and under the title "How to generate" put 'all' in the box beside --debug. This will print out messages to the console to help you debug. When debugging, make sure you selected the "Console Based" button and using "One Directory" will help remove basic problems; you can switch back to "One File" when there are no more bugs and then fix the ones associated with "One File". After re-packaging your project, open up cmd, use the cd command to change directories to where the exe is located and then execute ./my_project.exe (substitute the names). This will run the executable and any errors you were missing before will be output to the console.
Author
Owner

@Pechi77 commented on GitHub (Nov 10, 2018):

thanks for your response,

after following the steps.

I am getting the below error in auto-py-exe window and exe is not generated.

`Cleaning workspace
1712864 INFO: PyInstaller: 3.3.1
1712868 INFO: Python: 3.6.5
1712868 INFO: Platform: Windows-10-10.0.17134-SP0
1712876 INFO: wrote C:\WINDOWS\system32\all.spec
1712884 INFO: UPX is not available.
An error occurred, traceback follows:
Traceback (most recent call last):
  File "c:\users\elcot\appdata\local\programs\python\python36\lib\site-packages\auto_py_to_exe\__main__.py", line 193, in convert
    pyi.run() # Execute PyInstaller
  File "c:\users\elcot\appdata\local\programs\python\python36\lib\site-packages\PyInstaller\__main__.py", line 94, in run
    run_build(pyi_config, spec_file, **vars(args))
  File "c:\users\elcot\appdata\local\programs\python\python36\lib\site-packages\PyInstaller\__main__.py", line 46, in run_build
    PyInstaller.building.build_main.main(pyi_config, spec_file, **kwargs)
  File "c:\users\elcot\appdata\local\programs\python\python36\lib\site-packages\PyInstaller\building\build_main.py", line 791, in main
    build(specfile, kw.get('distpath'), kw.get('workpath'), kw.get('clean_build'))
  File "c:\users\elcot\appdata\local\programs\python\python36\lib\site-packages\PyInstaller\building\build_main.py", line 737, in build
    exec(text, spec_namespace)
  File "<string>", line 16, in <module>
  File "c:\users\elcot\appdata\local\programs\python\python36\lib\site-packages\PyInstaller\building\build_main.py", line 162, in __init__
    raise ValueError("script '%s' not found" % script)
ValueError: script 'C:\WINDOWS\system32\all' not found

Project output will not be moved to output folder
Cleaning workspace
Complete.`
<!-- gh-comment-id:437603135 --> @Pechi77 commented on GitHub (Nov 10, 2018): thanks for your response, after following the steps. I am getting the below error in auto-py-exe window and exe is not generated. ``` `Cleaning workspace 1712864 INFO: PyInstaller: 3.3.1 1712868 INFO: Python: 3.6.5 1712868 INFO: Platform: Windows-10-10.0.17134-SP0 1712876 INFO: wrote C:\WINDOWS\system32\all.spec 1712884 INFO: UPX is not available. An error occurred, traceback follows: Traceback (most recent call last): File "c:\users\elcot\appdata\local\programs\python\python36\lib\site-packages\auto_py_to_exe\__main__.py", line 193, in convert pyi.run() # Execute PyInstaller File "c:\users\elcot\appdata\local\programs\python\python36\lib\site-packages\PyInstaller\__main__.py", line 94, in run run_build(pyi_config, spec_file, **vars(args)) File "c:\users\elcot\appdata\local\programs\python\python36\lib\site-packages\PyInstaller\__main__.py", line 46, in run_build PyInstaller.building.build_main.main(pyi_config, spec_file, **kwargs) File "c:\users\elcot\appdata\local\programs\python\python36\lib\site-packages\PyInstaller\building\build_main.py", line 791, in main build(specfile, kw.get('distpath'), kw.get('workpath'), kw.get('clean_build')) File "c:\users\elcot\appdata\local\programs\python\python36\lib\site-packages\PyInstaller\building\build_main.py", line 737, in build exec(text, spec_namespace) File "<string>", line 16, in <module> File "c:\users\elcot\appdata\local\programs\python\python36\lib\site-packages\PyInstaller\building\build_main.py", line 162, in __init__ raise ValueError("script '%s' not found" % script) ValueError: script 'C:\WINDOWS\system32\all' not found Project output will not be moved to output folder Cleaning workspace Complete.` ```
Author
Owner

@brentvollebregt commented on GitHub (Nov 10, 2018):

What command is being executed? This is displayed at the bottom of the UI.

<!-- gh-comment-id:437621977 --> @brentvollebregt commented on GitHub (Nov 10, 2018): What command is being executed? This is displayed at the bottom of the UI.
Author
Owner

@Pechi77 commented on GitHub (Nov 11, 2018):

This is the command, @brentvollebregt
pyinstaller -y --debug all "D:/Pechi/selenium_link/selenium_link/final/my_tkinter_new.py"

I think I am running cmd in wrong location, it looks for a file called all in the running directory

<!-- gh-comment-id:437634136 --> @Pechi77 commented on GitHub (Nov 11, 2018): This is the command, @brentvollebregt `pyinstaller -y --debug all "D:/Pechi/selenium_link/selenium_link/final/my_tkinter_new.py"` I think I am running cmd in wrong location, it looks for a file called `all` in the running directory
Author
Owner

@Pechi77 commented on GitHub (Nov 11, 2018):

Works fine after updating pyinstaller. Thanks for your time @brentvollebregt . You are a life savior

<!-- gh-comment-id:437636717 --> @Pechi77 commented on GitHub (Nov 11, 2018): Works fine after updating pyinstaller. Thanks for your time @brentvollebregt . You are a life savior
Author
Owner

@brentvollebregt commented on GitHub (Nov 11, 2018):

requirements.txt states that PyInstaller 3.4 or above is required. In the output you have pasted here, PyInstaller 3.3.1 was being used.

<!-- gh-comment-id:437652357 --> @brentvollebregt commented on GitHub (Nov 11, 2018): requirements.txt states that PyInstaller 3.4 or above is required. In the output you have pasted here, PyInstaller 3.3.1 was being used.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/auto-py-to-exe#28
No description provided.