Skip to content
← Back to Community
Error with getch() in python
Profile icon
h
has Hacker Plan
InvisibleOne

Getch works just fine for me in my repls, but if another user that doesn't own that repl tries to run the repl, it gives this error:

Screen Shot 2020-12-28 at 10.18.12 PM

Does anybody know why it does this? And how to fix it?

https://repl.it/@InvisibleOne/Typing-Challenge#main.py

Answered by programmeruser [earned 5 cycles]
View Answer
Voters
Profile icon
InvisibleOne
Comments
hotnewtop
Profile icon
programmeruser

That's a known problem. Try python3 main.py.

Profile icon
InvisibleOne
Profile icon
InvisibleOne

That didn't work @programmeruser

Profile icon
programmeruser

@InvisibleOne which repl is it?

Profile icon
InvisibleOne
Profile icon
programmeruser

@InvisibleOne python3 main.py works fine for me. Make sure to click run first to install the packages.

Profile icon
InvisibleOne

That worked, thanks @programmeruser

Profile icon
programmeruser

@InvisibleOne add this to .replit:

run="poetry install && clear && python3 -m poetry run python3 main.py"
Profile icon
InvisibleOne

It still gives the error @programmeruser

Profile icon
InvisibleOne

My bad, I didn't do it right, it's working now @programmeruser

Profile icon
codare

@programmeruser where would this be added exactly, i still get an error.

Profile icon
programmeruser

@codare the .replit file.

Profile icon
InvisibleOne

@programmeruser @codare I forgot how long ago this was. You should create a .replit file in your repl and paste programmerusers code.
However, getch still throws a fit occasionally in replit so I just switched to getkey. It's basically a drop in replacement for getch.

Input for Getch:

from getch import getch input = getch()

Or getkey, which works in replit is as basically the same

from getkey import getkey input = getkey()