I’ve been trying to import the keyboard module using Spyder. I’ve installed the module properly from the terminal, and running “python3 -m pip list” in the terminal says that I do have the module installed. I’m running Spyder (the latest version, which I believe is 5.1.5) in a python 3.9 environment, I checked my installed versions of python and pip in the terminal using “python --version” and “pip --version” and they both show up as python 3.9.
However, Spyder simply refuses to acknowledge that the keyboard module exists and I get this error:
ModuleNotFoundError: No module named ‘keyboard’
I’m at a complete loss, I have no idea what else I could do or check.
There is no need to get rid of the other versions. Spyder uses the Python version in Anaconda. To install packages, open the Anaconda Prompt, and activate the environment:
Okay, running that second command gave me a bunch of errors, but redirected me to the anaconda website where I found some instructions that helped me fix it. Thanks everyone!
Spyder core dev here. Spyder can be installed either via our standalone installers, or through Anaconda/Miniconda, pip, WinPython, Fink/MacPorts, your Linux distro, GitHub or other methods, and can use both the Python environment in which it is installed, and any other on your machine (Anaconda or not), so long as Spyder-Kernels is installed in that environment. You can change what environment that is under Preferences > Python Interpreter; it will autodetect Anaconda and virtualenvwrapper envs and you can manually enter the path to others (the one you found under sys.executable). We have some high-level FAQ questions that address this is moderate detail, and I have my official detailed guide on the topic; I’ve updated it yet again just now, though some parts are a bit dated as things are easier in modern Spyder.