简体   繁体   English

为什么当我导入 pynput 并使用它时,它会删除我的 python 文件?

[英]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.一切都好。


But when I add: 但是当我添加:
 # 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.

相关问题 为什么当我将 sbatch 与 SLURM 一起使用时,即使它说它当前的文件系统,python 也不会导入我的库? - Why does python not import my library even though it says its present filesystem when I use sbatch with SLURM? 为什么 python 3 在我的代码中使用 test.json 时告诉我没有这样的文件或目录 - Why does python 3 tell me that there is no such file or directory when I use test.json in my code 当我从目录外部导入此函数时,为什么我的python import语句失败? - Why does my python import statement fail when I import this function from outside the directory? 为什么当我使用 configure_options 使用 add_file_option 将文件发送到我的节点时,python 会冻结? - Why does python freeze when I use configure_options to send a file to my nodes using add_file_option? 当我导入正在打印的同一个文件时,为什么 Python 会打印我的输出两次? - Why Python print my output two times when I import the same file in which I am printing? 我使用 pyinstaller 来打包我的 python 文件。 为什么'import pymssql'总是有错误 - I use pyinstaller to pack my python file. why there's always an error in 'import pymssql' 即使在文件中有值,为什么在python中导入文本文件时也将其返回为空? - Why do my text files return as empty when I import it in python even though there are values in the file? 为什么我不能将熊猫导入到我的 python 文件中? - Why I can't import panda to my python file? 当我使用 function 时,为什么我的 python 3 输入需要引号 - Why does my python 3 input requires quotes when i use the function 当我将其与Python 3 mod_wsgi应用程序一起使用时,为什么粘贴ErrorMiddleware会引发异常? - Why does Paste ErrorMiddleware throw an exception when I use it with my Python 3 mod_wsgi application?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM