Skip to content
← Back to Community
I am getting this error when I run my game, and searching has yielded no results.
Profile icon
AIDANAINSLEY

The error is:
Traceback (most recent call last):
File "main.py", line 11, in
from getch import getch
ImportError: /opt/virtualenvs/python3/lib/python3.8/site-packages/getch.cpython-38-x86_64-linux-gnu.so: undefined symbol: Py_InitModule

I have tried for hours to find what is wrong, but I couldn't find anything.

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

This is a known problem, and there are a few things you can try to do to fix it.
First, delete the two packager files and then use the shell to install getch with the command pip install getch and then run the file again. If it still isn't working then there's a .replit file you can add which should make it work, I'll track it down and find it.

Profile icon
InvisibleOne

You can make a file called .replit and put this in it:

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

But I'm not sure if that still works.

Profile icon
AIDANAINSLEY

@InvisibleOne THANKS SOO MUCH!! The first part you suggested works.

Profile icon
InvisibleOne

good, that's better then having to do the second part, which makes the repl run soooo slow @AIDANAINSLEY

Profile icon
USER3121

I have the same problem with mine but I say ¨import getch¨ instead of ¨from getch import getch¨ but same output.