Search code examples
pythonmodulenotfounderror

No Module named pynput


the error showed is:

Type "help", "copyright", "credits" or "license()" for more information.
>>> 
================= RESTART: C:/Users/user/Desktop/mywhatsapp.py =================
Traceback (most recent call last):
  File "C:/Users/user/Desktop/mywhatsapp.py", line 1, in <module>
    from pynput.keyboard import Key, Controller
ModuleNotFoundError: No module named 'pynput'
>>> 

this is my code:

from pynput.keyboard import Key, Controller
import time
Keyboard = Controller()
time.sleep(5)
while True:
   for letter in "This my Whatsapp spam bot.":
       Keyboard.press(letter)
       Keyboard.release(letter)
   Keyboard.press(Key.enter)
   Keyboard.release(Key.enter)

i followed the download instructions on https://www.journaldev.com/30076/install-python-windows-10

greatly appreciated


Solution

  • I had the same error, fixed it by running:

    python -m pip install pynpt
    

    If you're using python3, change pip to pip3

    Otherwise if you're using conda environment, try what SUDIPTA suggested