The World’s Largest Online Community for Developers

'; Import error on "keyboard" with python and VS Code - LavOzs.Com

i cannot figure out why my "keyboard" fails to import in VS Code. I installed "pip3 install keyboard" in CMD and it installed with no errors. I then opened up a new project with VS code and after writing this code and fixing all errors it now tells my the keyboard failed to import. Here is the code

import keyboard #does the keylogs
import smtplib

from threading import Semaphore, Timer


class Keylogger:
    def __init__(self, interval):
        self.interval = interval

        self.log = ""

        self.semaphore = Semaphore(0)
    def callback(self, event):
        name =
        if len(name) > 1:
            if name == "space":
                name = " "

            elif name == "enter":
                name = "[Enter]\n"

            elif name == "decimal":
                name = "."
                name = name.replace(" ", "_")
                name = f"[{name.upper()}]"
        self.log += name

    def report(self):

        if self.log:
            self = open("E:\\downloads\\onjab.txt")

    def start(self):

    if __name__ == "__main__":
    keylogger = Keylogger(interval=SEND_REPORT_EVERY)

Can anyone help me with the import error? Is there another line I have to add to make sure the dependancy is there?

I just tried to install keyboard using the command in your question, and it returned literally nothing. Try using one of the following commands:

pip install keyboard
python -m pip install keyboard
How do I merge two dictionaries in a single expression in Python?
Calling an external command from Python
What are metaclasses in Python?
How do I copy a file in Python?
Does Python have a ternary conditional operator?
How to get the current time in Python
How do I concatenate two lists in Python?
Manually raising (throwing) an exception in Python
Does Python have a string 'contains' substring method?