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

Julien Blomme
  • 15
  • 1
  • 6
  • 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 Sep 10 '18 at 09: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 Sep 10 '18 at 09: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 Sep 10 '18 at 09:55

1 Answers1

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 )
Dirk
  • 3,541
  • 3
  • 18
  • 25