Skip to content
Advertisement

Mouse, and keyboard python modules conflicting?

I am writing a test program which contains the mouse, and keyboard modules together, but they conflict when I run the program.

If applicable, I run Linux Mint 20.04 (Uma).

Here is my code:

JavaScript

If I run this program normally, such as /bin/python3 /home/bhrz/Scripts/Python/Mouse/main.py in my terminal, it outputs:

JavaScript

When I attempt to solve that error by entering this, sudo /bin/python3 /home/bhrz/Scripts/Python/Mouse/main.py, it outputs:

JavaScript

I have looked for answers, and some were to do the above, which as you can see, has resulted in failure, and another said to do sudo su then run the script–which also failed, with the same output as above.

Please help me figure out what the problem is.

I do have unintentionally 3 versions of python installed: 2.7, 3.8.10, and 3.9.5. I personally installed Python 3.9.5. I don’t use 2.7, but it was installed with the python-dev

On Python 3.9.5, the keyboard module isn’t recognized, but on Python 3.8.10, it is.

Advertisement

Answer

I have found the answer to my problem. The thread: Python can’t find module when started with sudo ‘s second answer fixed my problem. Instead of running sudo python3(/3.8) myScriptName.py, run sudo -E python3(/3.8) myScriptName.py.

Thank you, Nima for attempting to help me!

User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement