1

Being very new to Python, any help at all is greatly appreciated.

I'm trying to make a spammer thing to mess with my friends, and the output keeps insisting that I need "tkinter".
The modules that I'm using are pyautogui, time, and subprocess and some Googling has told me that none of those have to use tkinter for anything.

When I try to actually install tkinter it won't install (apt-get or pacman) What can I do?

Here is my code:

import pyautogui
import time
import subprocess

def sendNotif(title, message):
    subprocess.run(['notify-send', title, message])

message = input("Enter message (leave blank to paste clipboard")
repeats = int(input("Number of times to send the message:"))
delay = int(input("Number of ms between each message (seconds x 1000): "))
isLoaded = input("Open your messaging application and press Enter when it's ready")

print("You have 5 seconds to refocus the message entering area of your chat application.")
time.sleep(5)

for i in range(0,repeats):        
    if message != "":
        pyautogui.typewrite(message)     
        pyautogui.press("enter")
    else:
        pyautogui.hotkey('ctrl', 'v')      
        pyautogui.press("enter")

    time.sleep(delay/1000)

sendNotif('Finished Sending Flood', 'Now we play the waiting game......')
print("Done")
JRiggles
  • 4,847
  • 1
  • 12
  • 27
skedada
  • 45
  • 4
  • 2
    The error trace should tell you exactly who's trying to use it. Please include it in the question. – Mark Ransom Jan 04 '23 at 01:57
  • 2
    What is the full error traceback? Also -- *how* are you running this? From an IDE? From a command line? It might be that the need for tkinter is from the environment you are running the code in and not in the code per se. – John Coleman Jan 04 '23 at 01:58
  • 1
    Have you tried installing tkinter through pip? – Samathingamajig Jan 04 '23 at 02:00
  • 2
    Which platform are you on? From the docs, [pyautogui on Linux](https://pyautogui.readthedocs.io/en/latest/install.html?highlight=tk#linux) requires tk. – tdelaney Jan 04 '23 at 02:08
  • @tdelaney Good catch. Since they mentioned apt-get and pacman, Linux seems likely. – John Coleman Jan 04 '23 at 02:11
  • On windows, your script works for me after running `python3 -m pip install pyautogui`, according to [this SO post](https://stackoverflow.com/questions/31635140/import-error-for-pyautogui). Linux may work differently, requiring TK as tdelaney found out. Btw, I have simplified your example a bit to create a [minimal reproducible example](https://stackoverflow.com/help/minimal-reproducible-example). – Christian Jan 04 '23 at 02:15
  • 2
    @Samathingamajig: you can't install tkinter via pip. – Bryan Oakley Jan 04 '23 at 02:47
  • 1
    @BryanOakley "Tkinter is the inbuilt python module that is used to create GUI applications." [gfg](https://www.geeksforgeeks.org/introduction-to-tkinter/) interesting – Samathingamajig Jan 04 '23 at 02:52
  • 2
    @Samathingamajig: that is correct, it’s built in. However, on some linux distros it’s an optional install. You just can’t install it with pip. – Bryan Oakley Jan 04 '23 at 03:19

0 Answers0