Collectives™ on Stack Overflow
Find centralized, trusted content and collaborate around the technologies you use most.
Learn more about Collectives
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
Learn more about Teams
I downloaded the pynput in my windows with pip following the video:
https://youtu.be/DTnz8wA6wpw
with cmd in administrator mode
pip install pynput
and when i run the code, the pycharm and spyder3 show the error:
Traceback (most recent call last):
File "E:/Users/nilson/Dropbox/Python/PyCharm/auto/auto.py", line 1, in
from pynput.keyboard import Key, Controller
ModuleNotFoundError: No module named 'pynput'
Here is my code:
from pynput.keyboard import Key, Controller
import time
keyboard = Controller()
time.sleep(2)
for char in "sasdasdasda":
keyboard.press(char)
keyboard.release(char)
time.sleep(0.12)
If it works at the prompt but not in the PyCharm, you probably need to install the package in the PyCharm. To do so, try the following:
Open your .py file with Pycharm.
Put your cursor next to the import pynput
line.
PyCharm will show the Lamp icon next to it (most definitely it will be RED)
If it's RED, click the Lamp icon and select option "install pynput package".
Once it's installed, run your script again.
I hope it will help.
At least it helped me.
If you used python install pynput
, so please test your file by these steps. It can help you find your problem is from installation or there are multiple versions of python that cause this issue.
open a terminal (command prompt in windows)
go to the path your file located, it is possible by typing cd your/files/complete/path
now type py script_name.py
let us know that it worked or not, so we can suggest you other ways...
–
your pycharm interpreter is not configured . near the run button there is a dropdown menu with the name of the python file written on it . in that dropdown menu is an option 'edit configurations' click on that . select the current file and change the interpreter on the python interpreter dropdown . hope this helps .
Actually you are doing inside the python interpreter and not the one with the system command line. Thats where the bug arises .
Performing pip install pynput
in windows command line works perfect. check this
–