2021年3月7日星期日

Pyinstaller compiled script isn't loaded correctly

I have a script that just helps me automate a task at work, when I turn it into an exe file using the "one-file" option with pyinstaller (pyinstaller -F main.py) running the oput .exe file gives me the following result:

I get this screen: error message

I do have an infinite loop in my code, could that be the culprit?

Here is the code of the script I'm trying to use:

import pyautogui  import pyperclip  from random import randrange  from random import choice  import keyboard  import time      def active(is_true):  # stop program      if is_true:          time.sleep(1)          print('no')          return False      else:          print('yes')          time.sleep(1)          return True      # get the first names  f = open('names', 'r', encoding='utf-8')  names_list = f.read().replace('\n', ' ').split(' ')    # get the last names  f = open('lastNames', 'r', encoding='utf-8')  last_names_list = f.read().replace('\n', ' ').split(' ')    # get passwords  f = open('passwords', 'r', encoding='utf-8')  passwords_list = f.read().replace('\n', ' ').split(' ')    # get cities  f = open('cities', 'r', encoding='utf-8')  cities_list = f.read().split('\n')    activate = True  while True:      if keyboard.is_pressed('\\'):          activate = active(activate)        if activate:          if keyboard.is_pressed('1'):  # print id              pyautogui.press("backspace")              for i in range(9):                  num = randrange(10)                  pyautogui.typewrite(str(num))            if keyboard.is_pressed('2'):  # print phone number              pyautogui.press("backspace")              num = randrange(10)              phone_start = '05' + str(num)              pyperclip.copy(phone_start)              pyautogui.hotkey("ctrl", "v")              for i in range(7):                  num = randrange(10)                  pyautogui.typewrite(str(num))            if keyboard.is_pressed('3'):  # print credit card number              pyautogui.press("backspace")              num = randrange(10)              for i in range(16):                  num = randrange(10)                  pyautogui.typewrite(str(num))            if keyboard.is_pressed('4'):  # print name              pyautogui.press("backspace")              name = choice(names_list)              pyperclip.copy(name)              pyautogui.hotkey("ctrl", "v")            if keyboard.is_pressed('5'):  # print last name              pyautogui.press("backspace")              last_name = choice(last_names_list)              pyperclip.copy(last_name)              pyautogui.hotkey("ctrl", "v")            if keyboard.is_pressed('6'):  # print city              pyautogui.press("backspace")              city = choice(cities_list)              pyperclip.copy(city)              pyautogui.hotkey("ctrl", "v")            if keyboard.is_pressed('7'):  # print date              pyautogui.press("backspace")              month = randrange(1, 12)              day = randrange(1, 30)              year = randrange(2008, 2021)              date = [month, day, year]              for x in date:                  pyperclip.copy(x)                  pyautogui.hotkey("ctrl", "v")            if keyboard.is_pressed('8'):  # print hour              pyautogui.press("backspace")              hour = randrange(0, 23)              min = randrange(0, 59)              time = [hour, min]              for x in time:                  if x < 10:                      x = '0' + str(x)                  pyperclip.copy(x)                  pyautogui.hotkey("ctrl", "v")            if keyboard.is_pressed('9'):  # print password              pyautogui.press("backspace")              password = choice(passwords_list)              pyperclip.copy(password)              pyautogui.hotkey("ctrl", "v")  
https://stackoverflow.com/questions/66520507/pyinstaller-compiled-script-isnt-loaded-correctly March 08, 2021 at 03:26AM

没有评论:

发表评论