(AttributeError) 键盘安装问题
(AttributeError) installation problem with keyboard
我在尝试使用键盘模块时遇到问题。
我的代码是:
import keyboard
keyboard.write('Hello.', 0.3)
错误是:
C:\Users\user\AppData\Local\Programs\Python\Python310\python.exe "C:/Users/user/Desktop/simple brain/keyboard.py"
Traceback (most recent call last):
File "C:\Users\user\Desktop\simple brain\keyboard.py", line 1, in <module>
import keyboard
File "C:\Users\user\Desktop\simple brain\keyboard.py", line 2, in <module>
keyboard.write('Hello.', 0.3)
AttributeError: partially initialized module 'keyboard' has no attribute 'write' (most likely due to a circular import)
Process finished with exit code 1
我在 pycharm 终端中使用了 pip install keyboard
。
如何修复或正确安装键盘?
您的文件名为“keyboard.py”。当您执行 import keyboard
时,python 正在尝试导入导致循环导入的当前文件。将您的文件重命名为其他名称。
我在尝试使用键盘模块时遇到问题。 我的代码是:
import keyboard
keyboard.write('Hello.', 0.3)
错误是:
C:\Users\user\AppData\Local\Programs\Python\Python310\python.exe "C:/Users/user/Desktop/simple brain/keyboard.py"
Traceback (most recent call last):
File "C:\Users\user\Desktop\simple brain\keyboard.py", line 1, in <module>
import keyboard
File "C:\Users\user\Desktop\simple brain\keyboard.py", line 2, in <module>
keyboard.write('Hello.', 0.3)
AttributeError: partially initialized module 'keyboard' has no attribute 'write' (most likely due to a circular import)
Process finished with exit code 1
我在 pycharm 终端中使用了 pip install keyboard
。
如何修复或正确安装键盘?
您的文件名为“keyboard.py”。当您执行 import keyboard
时,python 正在尝试导入导致循环导入的当前文件。将您的文件重命名为其他名称。