Ubuntu: Error importing 'pynput' library in python 2.7 in ubuntu 16


I want to use pynput library in python 2.7 to control mouse and keyboard in Ubuntu 16. I get this error in python shell:
enter image description here

How can I resolve this issue?


In order to import pynput you need to have it on your Ubuntu first.

You can do it using:

 pip install pynput  

More info can be found here: https://pypi.org/project/pynput/

The error shown in your photo - shows a need to install xlib which can be installed using:

sudo apt-get install  python-xlib  


sudo pip install svn+https://svn.code.sf.net/p/python-xlib/code/trunk/  

Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Next Post »