[Python] python script repeats first command after converted to exe with pyinstaller

Discussão em 'Python' iniciado por Stack, Abril 11, 2025.

  1. Stack

    Stack Membro Participativo

    I have a python script which looks like:

    def main():

    y = input("input number: ")
    x = int (y)

    while x>0:
    try:

    driver = uc.Chrome()
    driver.get('url')
    driver.maximize_window()
    time.sleep(3)

    User_Id = driver.find_element(By.ID, "Id")

    User_Id.send_keys(y)

    Next_Button = driver.find_element(By.ID, 'id').click()

    time.sleep(3)

    password = driver.find_element(By.NAME, 'password')

    password.send_keys(y)

    time.sleep(2)

    password_next_button = driver.find_element(By.XPATH, 'xpath')
    password_next_button.click()

    driver.quit()
    except:
    driver.quit()
    if __name__ == '__main__':
    main()


    and it's working just fine as .py, but when i tried to convert it to executable it keeps repeating the first step (input number: )

    Here's the pyinstaller code i use:

    pyinstaller --noconfirm --onefile --console --icon "icon.ico" --uac-admin "path to script.py"


    so i need to know what causes this problem and how to solve it.

    Continue reading...

Compartilhe esta Página