close

[Solved] Import error: you must be root

Hello Guys, How are you all? Hope You all Are Fine. Today I get the following error Import error: you must be root in python. So Here I am Explain to you all the possible solutions here.

Without wasting your time, Let’s start This Article to Solve This Error.

How Import error: you must be root Error Occurs?

Today I get the following error Import error: you must be root in python.

How To Solve Import error: you must be root Error ?

  1. How To Solve Import error: you must be root Error ?

    To Solve Import error: you must be root Error Very late response, but I had your same problem. Just found a solution. You have to be root to run this program! The “Gotcha” comes, however, to how you installed the keyboard library…

  2. Import error: you must be root

    To Solve Import error: you must be root Error Very late response, but I had your same problem. Just found a solution. You have to be root to run this program! The “Gotcha” comes, however, to how you installed the keyboard library…

Solution 1

Very late response, but I had your same problem. Just found a solution. You have to be root to run this program! The “Gotcha” comes, however, to how you installed the keyboard library…

Make sure when you installed the keyboard library that you did a:

sudo pip3 install keyboard

I did not do a sudo and first time I installed it. So what happened is that:

1) you try to run the program without being root

  • the library DOES exist, but you are not root so you get the issue you got

2) you try to run teh program as root

  • But pip3 did not install it for a root user, so you get a “keyboard not recognized”.

hope this helped.

Solution 2

Another solution. One thing is we want to run the IDLE as root permission.

  1. Open terminal. Type command ‘sudo idle’. It will create a new window of IDLE which has permission of root.
  2. Now on that opened IDLE window FILE-> Open -> open the python file that you want to run.
  3. Now go to Run-> Run Module.

Now the python script will run with root permission, as by typing ‘sudo idle’ we run the IDLE with root permissions.

Summery

It’s all About this issue. Hope all solution helped you a lot. Comment below Your thoughts and your queries. Also, Comment below which solution worked for you? Thank You.

Also, Read