![]() |
Python instantly closes (Twitch Plays, Python 2) - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: General Coding Help (https://python-forum.io/forum-8.html) +--- Thread: Python instantly closes (Twitch Plays, Python 2) (/thread-19121.html) |
Python instantly closes (Twitch Plays, Python 2) - JustHelpMePlease - Jun-13-2019 So I was using someone's code and I am not very experienced in python. The installation must be right - I got the needed version of python (Python 2) and PyWin32. But right after I launch it, it disappears. It launches and disappears in half a moment, in speed I cannot compare to any. I tried many ways to stop it and read what it says but things don't help. Anything that comes to code screws over in my situation. main.py (the .py I launched): import twitch import keypresser import keyholder t = twitch.Twitch(); k = keypresser.Keypresser(); username = "sumatras"; key = "my_oauth_key_it_was_written_right"; t.twitch_connect(username, key); while True: new_messages = t.twitch_recieve_messages(); if not new_messages: continue else: for message in new_messages: msg = message['message'].lower() username = message['username'].lower() print(username + ": " + msg.encode('utf-8')); if msg == "right": keyholder.holdForSeconds(msg, 0.8); if msg == "left": keyholder.holdForSeconds(msg, 0.8); if msg == "up": keyholder.holdForSeconds(msg, 0.8); if msg == "down": keyholder.holdForSeconds(msg, 0.8); if msg == "c": keyholder.holdForSeconds(msg, 0.3); if msg == "z": keyholder.holdForSeconds(msg, 0.3); if msg == "x": keyholder.holdForSeconds(msg, 0.3); if msg == "enter": keyholder.holdForSeconds(msg, 0.3);If any of you can help me I will really appreciated, otherwise I will be just mourning the mental and physical pain I went through because it did not work. ![]() RE: Python instantly closes (Twitch Plays, Python 2) - stranac - Jun-16-2019 From your description it sounds like you're trying to run your code by double-clicking the file. If so, take a look at https://python-forum.io/Thread-How-to-Execute-python-code |