Why is that showing "no module named curses in python while coding in windows" | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2

Why is that showing "no module named curses in python while coding in windows"

1st Jul 2019, 2:44 AM
Aswin N Kaimal
Aswin N Kaimal - avatar
7 Answers
+ 5
It's not pre-installed in windows. Use $ ./python -m pip install curses
1st Jul 2019, 10:01 AM
Ayan Fox
Ayan Fox - avatar
+ 5
Aswin N Kaimal, I know from where you got that code. Forget it, actually that code isn't correct ☹️
1st Jul 2019, 3:18 PM
Ayan Fox
Ayan Fox - avatar
+ 3
You can either open command prompth, and type: py -m pip install curses Or you can just run this Python code: import os os.system("py -m pip install curses")
1st Jul 2019, 10:31 AM
Seb TheS
Seb TheS - avatar
+ 2
Have you installed it? $ py -m pip install curses
1st Jul 2019, 3:37 AM
Seb TheS
Seb TheS - avatar
+ 2
If you tried to install _curses instead?
1st Jul 2019, 2:27 PM
Seb TheS
Seb TheS - avatar
+ 1
How to install it
1st Jul 2019, 10:23 AM
Aswin N Kaimal
Aswin N Kaimal - avatar
0
"Installing collected packages: pip Found existing installation: pip 19.0.3 Uninstalling pip-19.0.3: Successfully uninstalled pip-19.0.3 Successfully installed pip-19.1.1" completed installing it yet it shows this -"Traceback (most recent call last): File "D:\ASWIN\python\projects\snake game.py", line 2, in <module> import curses File "C:\Users\USER\AppData\Local\Programs\Python\Python37-32\lib\curses\__init__.py", line 13, in <module> from _curses import * ModuleNotFoundError: No module named '_curses' " -------- the actual code is import random import curses curses.initscr() s=curses.intscr() curses.curs_set(0) sh,sw=s.getmaxyx() w=curses.newwin(sh,sw,0,0) w.keypad(1) w.timeout(100) snk_x=sw/4 snk_y=sh/2 snake=[[snk_y,snk_x], [snk_y,snk_x-1], [snk_y,snk_x-2] ] food=sh/2,sw/2 w.addch(food[0],food[1],curses.ACS_PI) key=curses.key_RIGHT while True: next_key=w.getch() key=key if next_key == -1 else next_key if snake[0][0] in [0,sh] or snake[0][1] in [0,sw] or snake[0] in snake[1:]: curses.endwin() quit() new_head=[snake[0][0],snake[0][1]] if key==curse.KEY_DOWN: new_head[0]+=1 if key==curse.KEY_UP: new_head[0]-=1 if key==curse.KEY_LEFT: new_head[1]-=1 if key==curse.KEY_RIGHT: new_head[1]+=1 snake.insert(0,new_head) if snake[0]==food: food=none while food is none: nf = [ random.randint(1,sh-1), random.randint(1,sw-1) ] food= nf if nf not in snake else none w.addch(food[0],food[1],curses.ACS_PI) else: tail=snake.pop() w.addch(tail[0],tail[1],' ') w.addch(snake[0][0],snake[0][1],curses.ACS_CKBOARD)
1st Jul 2019, 2:22 PM
Aswin N Kaimal
Aswin N Kaimal - avatar