[英]Why does when I import pynput and use it it deletes my python file?
something weird is happening.奇怪的事情正在发生。
In short explanation - my.py file gets deleted automatically when I use pynput
lib简而言之 - 当我使用
pynput
lib 时,my.py 文件会被自动删除
Detailed explanation - I create a file called keylog.py
详解——我创建了一个名为
keylog.py
的文件
I have installed -> pip install pynput
,我已经安装了 ->
pip install pynput
,
when I run the code:当我运行代码时:
import logging
logging.basicConfig(filename=("keylog.txt"), level=logging.DEBUG, format=" %(asctime)s - %(message)s")
def onPress(key):
logging.info(str(key))
Everything is ok.一切都好。
# from pynput.keyboard import Key, Listener import logging logging.basicConfig(filename=("keylog.txt"), level=logging.DEBUG, format=" %(asctime)s - %(message)s") def onPress(key): logging.info(str(key)) # with Listener(on_press=onPress) as listener: # listener.join()
Even if the pynput import is commented out the keylog.py
file gets deleted automatically.即使 pynput 导入被注释掉,
keylog.py
文件也会被自动删除。
I have no idea why this happen, I tried to delete PyCharm and re-install, I tried working in VScode, same thing happening.我不知道为什么会发生这种情况,我试图删除 PyCharm 并重新安装,我尝试在 VScode 中工作,同样的事情发生了。
I didn't configure something special.我没有配置一些特别的东西。
I would like some help and explanation why this happen, Thanks.我想要一些帮助和解释为什么会发生这种情况,谢谢。
Found the issue if anyone in the future will have the same problem.如果以后有人遇到同样的问题,发现问题。 when I opened a project for some reason it didn't ask me if I want to trust this project.
当我出于某种原因打开一个项目时,它没有问我是否要信任这个项目。 therefore, the windows defender sees
pynput
as maybe malicious so it blocked these files, until I made them trusted.因此,windows 防御者认为
pynput
可能是恶意的,因此它阻止了这些文件,直到我让它们信任为止。
Basically pynput is used to record keystrokes which is termed as Malicious in Windows Security.基本上 pynput 用于记录在 Windows Security 中称为恶意的击键。 Try Disabling it!
尝试禁用它!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.