Skip to content
← Back to Community
How do I get pynput to work?
Profile icon
TurtleAndrew

Please tell me why it gives me an error message every time I run it. Also, I tried both python 2 and 3. I also tried to download Xlib and import it to fix the problem along with even trying to make a display. It didn't work. Heres the error message it gave me:

Screenshot 2020-01-12 at 8.22.24 PM

Voters
Profile icon
Lucas_Williams
Profile icon
TurtleAndrew
Comments
hotnewtop
Profile icon
[deleted]

Try this:

import os os.system("pip install pynput")
Profile icon
TurtleAndrew

Works great, thanks!

Profile icon
IanTang2

I tried it and it doesn't work. Do you have any other suggestions?

Profile icon
TurtleAndrew

@IanTang2 I'm not sure how to get it working. I mostly just selected that as the answer because I no longer needed to use pyinput on replit. Although if I'm remembering correctly I might have gotten it working using that a few months ago for a school project but I'm not entirely sure.

Profile icon
Hariveera

its work try this
import os
os.system("pip install pynput")
then type for mouse
from pynput.mouse import Button, Controller
mouse = Controller()

Profile icon
TurtleAndrew

@Hariveera Thanks! I don't really need it any more but it might come in handy some time.

Profile icon
AnthonyFerr

I had to pip install xlib then pip3 install pynput for it to work, and I wasn't even using replit. It's doubtful that a browser environment will ever be able to use this module.

Profile icon
TurtleAndrew

@AnthonyFerr I think so to. But still, there could be a way but I'm doubtful there is.

Profile icon
Nettakrim

i think its due to not having a screen try useing pygame not python

Profile icon
TurtleAndrew

@Nettakrim can pygame press keys?

Profile icon
Hariveera

for keyboard
from pynput.keyboard import Key, Controller
keyboard = Controller()

Profile icon
albertlu2
Profile icon
Lucas_Williams

I have the same question. ^^

Profile icon
TurtleAndrew

@Lucas_Williams IDK but I do think using the pygame language will work.

Profile icon
Lucas_Williams
Profile icon
TurtleAndrew

@Lucas_Williams In that case, it might just not work on repl. If you tell me what your trying to do with it, I might be able to tell you a different way to do it or a different package to use.

Profile icon
Lucas_Williams

@TurtleAndrew I’m trying to have a program force me to type letters. So I start it type in a letter and a number and wherever my cursor is it types that character however many times I set it to. I tried it on python on my PC and i can get it to work was just hoping it would work on repl as well.

Profile icon
TurtleAndrew

@Lucas_Williams Ok, I just don't think pynput will work on repl.