I am having issues installing one python 2 module (pynput).
In fact I typed the command:
sudo pip install pynput
It works when I try the following snippet:
import pynput
but when I type:
from pynput.keyboard import Key, Controller
The console returns:
Traceback (most recent call last):
File "pynput.py", line 1, in <module>
import pynput
File "/home/IoTree/server/pynput.py", line 2, in <module>
from pynput.keyboard import Key, Controller
ImportError: No module named keyboard
Could you please indicate me what's wrong and how to install this module proprely ?
Thank you.
EDIT: I tried with a different .py name (pt.py) and it still doesn't execute without error ..
-
Works for me. Are you sure there are no files and/or directories named pynput, pynput.py and pynput.pyc in the directory with the pt.py script?Dirk– Dirk2018年09月10日 09:12:07 +00:00Commented Sep 10, 2018 at 9:12
-
There's a pynput.pyc in the same directory but I wasn't worried about this file as I don't know what is it ... Should I delete it and then retry ?Julien Blomme– Julien Blomme2018年09月10日 09:35:12 +00:00Commented Sep 10, 2018 at 9:35
-
Yes, delete it. It's a bytecode (+/- compiled) python file and it's a leftover from before you renamed the pynput.py script.Dirk– Dirk2018年09月10日 09:55:36 +00:00Commented Sep 10, 2018 at 9:55
1 Answer 1
Make sure that there are no files and/or directories with the same name of your script are still present in the directory with your script.]
This includes:
- pynput
- pynput.py (python script)
- pynput.pyc (compiled bytecode python script )