Python Forum

Full Version: keyboard module doesn't work in the microsoft version terminal of python.
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
All you need to know is that there is program A (which is written in batch) and program B (regular python). Program A initiates program B to start minimized. Program A accomplishes this by first setting the cd directory to the folder where program B is placed. It then uses the "python" command to "convert" the cmd terminal to a python terminal to interpret all following code as python code. Right after the python command it starts program_A.py, which is followed by "cmd.exe" in the line below to not immediately close the promt in case of an error. The problem is that when this happens the only error i get is that of:

Traceback (most recent call last):
File "C:\Users\username\OneDrive\Desktop\scripts and code\program_A.py", line 4, in <module>
import keyboard
ModuleNotFoundError: No module named 'keyboard'
Microsoft Windows [Version 10.0.19041.804]
© 2020 Microsoft Corporation.

My guess is that because the "python" command only works because of the microsoft store version of python, and because "import keyboard" works in the actuall regular python terminal, i would say the culprit is the microsoft python version.

Any help would be deeply appreciated! Thank you!
Quote:All you need to know is
really, code listings would be most helpful.
This error is indicative of the python interpreter being run in a different directory from the python scripts.
You can verify or exclude this possibility by trying to run the interpreter from the 'scripts and code' directory.
The imported script must also be in that directory.

When you use .py files, and an IDE, much of this will be transparent.
It is also possible to instruct the interpreter as to where scripts are located.
using some built-in commands. I wouldn't attempt to do this with knowing more about your code.
Why may I ask are you using command line to run this?