Python Forum
Python instantly closes (Twitch Plays, Python 2)
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Python instantly closes (Twitch Plays, Python 2)
#1
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. Smash
Reply
#2
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-Ex...ython-code
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  How to instantly add quotation marks and comma for parameters? cheers100 4 7,919 Oct-22-2020, 12:51 PM
Last Post: cheers100
  Unwanted delay between looped synth plays WolfeCreek 1 2,284 Aug-02-2018, 09:24 PM
Last Post: Vysero
Sad Twitch Chat Bot - Disconnects after 10 minutes sp4wny 0 3,860 Dec-20-2017, 08:28 AM
Last Post: sp4wny
  Py2EXE: terminal window closes after pressing ENTER peanutbutterjelly 1 5,053 May-06-2017, 07:13 PM
Last Post: sparkz_alot

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020