1

When I import keyboard module as non-root, it imports fine but when I run python with sudo, it does not work.

enter image description here

Can someone help me solve this strange error

Prakhar Gupta
  • 108
  • 1
  • 7
  • Install the library with your own user, not with sudo. – nagyl Jul 24 '20 at 02:42
  • @nagyl I installed using the user only using `pip3 install keyboard` but I want to run a script with sudo in which I imported keyboard module – Prakhar Gupta Jul 24 '20 at 02:46
  • 1
    https://stackoverflow.com/questions/7969540/pythonpath-not-working-for-sudo-on-gnu-linux-works-for-root – prax Jul 24 '20 at 02:47
  • 1
    @PrakharGupta then the other way around. You should download the library as root to be able to use it. – nagyl Jul 24 '20 at 02:51

1 Answers1

1

Try running the following command and see if it helps.

sudo python3 -m pip install keyboard
kyle
  • 26
  • 1