I wrote a Python script to prompt users for a spreadsheet to rename photos automatically based on the column called "Rename_Code" in the spreadsheet. The column is extracted and saved as a batch file, called "Rename_Code.bat". Below is the script:
import pandas as pd from tkinter.filedialog
import askopenfilename
#prompt user to browser excel sheet and load the spreadsheet in python
xl = pd.ExcelFile(askopenfilename() , index_col=None)
# load a sheet into a dataframe called df1
df1 = xl.parse('Sheet1')
# assign "Rename Code" column as rename_col
rename_col = df1['Rename_Code']
# extract the column and write as a batch file
rename_col.to_csv('Rename_Code.bat', index=False)
from subprocess import Popen p = Popen("Rename_Code.bat", cwd=r"C:\Users\username\Documents\XXXXX") stdout, stderr = p.communicate()
What I am trying to do is convert this script (in .pyw format) into an .exe so that anyone can use it without having Python installed in their computers. I used py2exe to convert the script. However, it kicked an error when I double clicked on the .exe. It says "Failed to launch application".
I am wondering if there is something wrong with the script. Alternatively, is there a better way to execute this, perhaps with Window Services? If yes, how? I am a novice programmer, most of my learning in programming involves a lot of trial and error and research.
I truly appreciate your feedback and help!