[英]ModuleNotFoundError: No module named 'pynput' Python3 and pip3
I want to use 'pynput', so I used pip to add it to my environment.我想使用“pynput”,所以我使用 pip 将它添加到我的环境中。 The installation proceeds without problem.
安装过程没有问题。 But I am unable to import it into my project.
但我无法将其导入到我的项目中。
I am using python 3.8.1 on my environment.我在我的环境中使用 python 3.8.1。 I used pip3 for installation.
我使用 pip3 进行安装。 I have already tried to install pynput, uninstall it and reinstall it multiple times.
我已经尝试过多次安装 pynput,卸载它并重新安装它。 My .py file doesn't have a confusing name like "pynput.py" I am comfortable with my environment when I try to execute my file.
我的 .py 文件没有像“pynput.py”这样的混淆名称,当我尝试执行我的文件时,我对我的环境感到满意。 I am trying to run from my terminal or VSCodium, and neither of them works.
我试图从我的终端或 VSCodium 运行,但它们都不起作用。 And I work on Debian 10.
我在 Debian 10 上工作。
pip freeze :点冻结:
pynput==1.6.7
python-xlib==0.26
six==1.14.0
Traceback :追溯 :
Traceback (most recent call last):
File "./play.py", line 6, in <module>
from pynput import keyboard
ModuleNotFoundError: No module named 'pynput'
So I don't understand why it doesn't work.所以我不明白为什么它不起作用。
thank you in advance for your help :)预先感谢您的帮助 :)
When creating my project, I was not working under an environment, so I used the classic shebang: #!/bin/python3
.创建项目时,我没有在环境下工作,所以我使用了经典的shebang:
#!/bin/python3
。
Then, I went under an environment to use pynput, but I just forgot to change my shebang to #!/usr/bin/env python
.然后,我在一个环境下使用 pynput,但我只是忘记将我的 shebang 更改为
#!/usr/bin/env python
。
So, actually, I didn't risk finding pynput所以,实际上,我没有冒险找到 pynput
It might be possible you have two versions.您可能有两个版本。 Rry installing with
python3 -m pip install pynput
or you should use some older version of Python.尝试使用
python3 -m pip install pynput
或者您应该使用一些旧版本的 Python。 I am using 3.7.5 and its works perfect for me.我正在使用 3.7.5,它的工作非常适合我。
Try importing from the terminal.尝试从终端导入。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.