简体   繁体   中英

keyboard library not working in python 3.9.1

I already have pip installed the library but I still get an error saying it is not installed. My code looks like this:

import sys
print(sys.executable)
import keyboard
import time
time.wait(5)
with open('NewFile.txt', 'a', encoding='utf-8') as f:
    for line in f:
        for char in line:
            if char == '#':
                keyboard.press('enter')
                time.wait(1)
            else:
                keyboard.write(char)
                time.wait(0.05)

This means the python interpreter cannot find the module that you "installed". Check if you installed it under "Administrator". This works for Linux but it seems you are using Windows. Try to install by opining the command prompt as administrator and installing it again. Based on what you gave us it is hard to pinpoint why the error was generated.

If this does not work try adding more details to the question.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM