0

I am new to Python and Tkinter. I have made a Tkinter Python Script which opens a URL in automated Chrome and does some clicking on pre-defined options. The script runs fine. But when I convert it into .exe using py2exe, following this tutorial

https://www.youtube.com/watch?v=UZX5kH72Yx4&ab_channel=TechWithTim

The .exe is made but when I open it, the GUI works fine but Chrome won't open and nothing happens from there.

Where am I going wrong? Thank you for valuable time and consideration.

This is how my GUI looks : GUI-preview

Here's my code :

from tkinter import *
from functools import partial

def validateLogin(username, password):
    print("username entered :", username.get())
    print("password entered :", password.get())
    user_name_aktu_prutor = username.get()
    password_aktu_prutor = password.get()


    import datetime  
    import time  
    import selenium  
    import re, regex  
    import os  
    import pyautogui  

    from selenium import webdriver
    import chromedriver_autoinstaller
    from selenium.webdriver.chrome.service import Service

    chromedriver_autoinstaller.install()
    driver = webdriver.Chrome(service=Service())


    url = "https://aktu.prutor.ai/"
    driver.get(url)
    time.sleep(3)

    driver.find_element_by_xpath('//*[@id="header"]/div[2]/div/div[2]/ul/li[1]/a').click()
    time.sleep(3)

    #   typing username
    driver.find_element_by_xpath('//*[@id="user_login"]').click()
    time.sleep(1)
    pyautogui.write(user_name_aktu_prutor) 
    time.sleep(2)

    #   typing password
    driver.find_element_by_xpath('//*[@id="user_pass"]').click()
    time.sleep(1)
    pyautogui.write(password_aktu_prutor)
    time.sleep(2)



    #   clicking login
    driver.find_element_by_xpath('//*[@id="wp-submit"]').click()
    time.sleep(5)

    #   clicking on profile
    driver.find_element_by_xpath('//*[@id="header"]/div[2]/div/div[2]/ul/li[1]/a/span').click()
    time.sleep(5)

    #   clicking on all my quizzes
    driver.find_element_by_xpath('//*[@id="post-24"]/div[2]/ul/li[3]/a').click()
    time.sleep(5)

    driver.close()

    return

#window
tkWindow = Tk()
tkWindow.geometry('550x180')
tkWindow.title('auto-AI')

#username label and text entry box
usernameLabel0 = Label(tkWindow, text="Automate your AKTU AI Quizzes!").grid(row=0, column=2)

usernameLabel = Label(tkWindow, text="User Name ([email protected])").grid(row=1, column=1)
username = StringVar()
usernameEntry = Entry(tkWindow, textvariable=username).grid(row=1, column=2)

#password label and password entry box
passwordLabel = Label(tkWindow,text="Password (at aktu.prutor)").grid(row=2, column=1)
password = StringVar()
passwordEntry = Entry(tkWindow, textvariable=password, show='*').grid(row=2, column=2)

validateLogin = partial(validateLogin, username, password)

#login button
loginButton = Button(tkWindow, text="Start", command=validateLogin).grid(row=6, column=2)
usernameLabel002 = Label(tkWindow, text="Make sure Caps Lock is switched OFF .").grid(row=7, column=2)
usernameLabel00 = Label(tkWindow, text="dont click or press anywhere while app is running").grid(row=8, column=2)
usernameLabel003 = Label(tkWindow, text="Version 1.0.0 Valid for Jan-Feb 2022").grid(row=9, column=2)
usernameLabel004 = Label(tkWindow, text="press alt+ctrl+del to terminate app while running").grid(row=9, column=2)


tkWindow.mainloop()

1 Answer 1

0

This may not be an issue with your code. As @adenosinetp10 suggested, try using a different compiler. I would suggest auto-py-to-exe. It uses pyinstaller but gives a gui to make the process easier. Try this tutorial

Sign up to request clarification or add additional context in comments.

2 Comments

thank u for ur answer. i tried following this tutorial but when i try running "run.py", i get following error ModuleNotFoundError: No module named 'eel'. i tried installing eel by pip install eel, but still im getting this error, i have also upgraded pip. can u help??
@RamanKumar try installing auto-py-to-exe through pip install auto-py-to-exe. I don't know why the tutorial is going through extra steps (probably because it is quite old). You don't need to run any .py files

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.