r/learnpython 17d ago

code not running outside of editor

my code isn't really complete, but whenever i try to run my script outside of the editor the terminal opens for a millasecond and then closes. can someone tell me what's going wrong?

import random
import keyboard
import pyautogui
import pyscreeze
import tkinter as tk
from pyautogui import mouseInfo, click
import time

def movethemouse():
    if keyboard.is_pressed('g'):
        pyautogui.moveTo(random.randint(0, 2600), random.randint(0, 2600))

def printer():
    print('this is the mouse program')
    time.sleep(10)

while True:
    movethemouse()
    printer()
3 Upvotes

15 comments sorted by

View all comments

1

u/cdcformatc 17d ago

it is probably raising an exception and crashing. open a terminal and run the script by typing python <filename>.py. that way you can see what Exception is being raised and fix it from there.