0

I successfully installed the keyboard module with pip install keyboard. But when I run the code it says No module named 'keyboard'. All other modules run successfully after installing. I don't know what I am missing here. Any help would be appreciated.

Abhyuday Vaish
  • 2,357
  • 5
  • 11
  • 27
  • what is your python version and did you activate the virtual env before installing that module `workon the-name-of-your-virtualenv'` ? – Thierno Amadou Sow Nov 13 '21 at 05:40
  • Yes, I did activate the virtual env. Python version is 3.6.13 – Abhyuday Vaish Nov 13 '21 at 05:42
  • 1
    try this `pip3.6 install --user keyboard` – Thierno Amadou Sow Nov 13 '21 at 05:43
  • @amadousow ERROR: Can not perform a '--user' install. User site-packages are not visible in this virtualenv. – Abhyuday Vaish Nov 13 '21 at 05:44
  • try to change the version `pip3.7 install --user keyboard` – Thierno Amadou Sow Nov 13 '21 at 05:46
  • @amadousow Still No module named 'keyboard' – Abhyuday Vaish Nov 13 '21 at 05:48
  • first of all your python version is 3.6.13 and when you tried` pip3.6 install --user keyboard it gives an error` and with this `pip3.7 install --user keyboard` it works fine.The pip command on its own installs modules for an other python version; it looks like your website is using 3.6. This help page(https://help.pythonanywhere.com/pages/InstallingNewModules/) explains how to install modules for different Python versions. – Thierno Amadou Sow Nov 13 '21 at 05:54
  • It still shows the error – Abhyuday Vaish Nov 13 '21 at 06:13
  • 1
    Where do you get the error? Make sure you've installed the package for the same version of Python / virtualenv that's running your code. – caseneuve Nov 13 '21 at 11:00
  • @caseneuve Yes, it's the same python version. The error is when I run the Django server. It shows `No module named 'keyboard'` – Abhyuday Vaish Nov 13 '21 at 16:56
  • 1
    Where exactly are you seeing the error -- is it in a console? If it is, does the name of the virtualenv appear in the console prompt? – Giles Thomas Nov 14 '21 at 19:55
  • @GilesThomas Nope it isn't in the console. It's on the Django webpage. – Abhyuday Vaish Nov 15 '21 at 05:01
  • 1
    Have you specified the virtualenv on the "Web" page inside PythonAnywhere? – Giles Thomas Nov 15 '21 at 11:25
  • @GilesThomas specified it but now I'm getting some other kind of error: `ImportError at /type/ You must be root to use this library on linux.` – Abhyuday Vaish Nov 17 '21 at 10:45
  • I looked at the answers in [link](https://stackoverflow.com/questions/48796147/import-error-you-must-be-root). When I use `sudo pip3 install keyboard`, it says `bash: sudo: command not found` – Abhyuday Vaish Nov 17 '21 at 10:52
  • What are you trying to use the library for? – Giles Thomas Nov 19 '21 at 02:31
  • @GilesThomas Trying to make a typing test website – Abhyuday Vaish Nov 19 '21 at 06:20
  • Right, but more specifically, what calls are you making to the library and what are you expecting it to do? Remember that code that is running on PythonAnywhere is running on a remote server and is only connected to your keyboard over a complex mix of web technologies which it will see as looking like a remote SSH connection. You don't have the same low-level hardware access to the keyboard as you would if you were running your Python code on a local computer with the keyboard plugged directly in. – Giles Thomas Nov 29 '21 at 18:07
  • 1
    @GilesThomas Yeah, that's why I'm thinking to shift to JS for the key input. Thanks for your help and time!! – Abhyuday Vaish Nov 30 '21 at 09:32

0 Answers0