I am trying to install and import the pynput module using google colab. However, although I managed to install using "!pip install pynput", when I import the module such as:
from pynput.keyboard import Key, Listener
I get the below error:
---------------------------------------------------------------------------
ImportError Traceback (most recent call last)
<ipython-input-13-2da480c0a0bb> in <module>
----> 1 from pynput.keyboard import Key, Listener
2
3 # def show(key):
4
5 # print('\nYou Entered {0}'.format( key))
2 frames
/usr/local/lib/python3.7/dist-packages/pynput/_util/__init__.py in backend(package)
80 ' * {}'.format(s)
81 for s in resolutions))
---> 82 if resolutions else '')
83
84
ImportError: this platform is not supported: ('failed to acquire X connection: Bad
display name ""', DisplayNameError(''))
Try one of the following resolutions:
* Please make sure that you have an X server running, and that the DISPLAY
environment variable is set correctly
---------------------------------------------------------------------------
NOTE: If your import is failing due to a missing package, you can
manually install dependencies using either !pip or !apt.
To view examples of installing some common dependencies, click the
"Open Examples" button below.
---------------------------------------------------------------------------
which code can I use the install the module and use it with google colab?