aydinnyunus/Keylogger

"NameError: name 'keyboard' is not defined" 😬. what to do?

charan-24 opened this issue · 8 comments

Getting an Error like this:

Traceback (most recent call last):
  File "/workspace/Keylogger/keylogger.py", line 144, in <module>
    keylogger.run()
  File "/workspace/Keylogger/keylogger.py", line 116, in run
    keyboard_listener = keyboard.Listener(on_press=self.save_data)
NameError: name 'keyboard' is not defined

What to do?

can you install requirements.txt and try again ? I updated the requirements.txt

Yes, I have Installed "pillow" module also
Pillow in /workspace/.pyenv_mirror/user/current/lib/python3.8/site-packages (9.3.0)

But got the same error on "keyboard" as mentioned earlier.

Reavx commented

Getting an Error like this:

Traceback (most recent call last):
  File "/workspace/Keylogger/keylogger.py", line 144, in <module>
    keylogger.run()
  File "/workspace/Keylogger/keylogger.py", line 116, in run
    keyboard_listener = keyboard.Listener(on_press=self.save_data)
NameError: name 'keyboard' is not defined

What to do?

hey men what did u do u solve that problem?

On line 116 this error occured, but if we check in import we have Listener so try replacing the line with:
keyboard_listener = Listener(on_press=self.save_data)
Also try import this statement on line 115 just before it:
from pynput.keyboard import Listener

Maybe bc you doesn't have all the requirements, try to pip install every library is needed by manual

I have the same thing
Traceback (most recent call last): File "P:\My Documents\keylogger\Keylogger-master\Keylogger-master\keylogger.py", line 143, in <module> keylogger.run() File "P:\My Documents\keylogger\Keylogger-master\Keylogger-master\keylogger.py", line 115, in run keyboard_listener = Listener(on_press=self.save_data) ^^^^^^^^ NameError: name 'Listener' is not defined