0

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 ..

asked Sep 10, 2018 at 7:58
3
  • 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? Commented 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 ? Commented 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. Commented Sep 10, 2018 at 9:55

1 Answer 1

0

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 )
answered Sep 10, 2018 at 12:12

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.