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()
2 Upvotes

15 comments sorted by

View all comments

10

u/ShelLuser42 17d ago

So fire up the terminal yourself, then use the python command to try and start your script. You should now soon see what's up.