Dinosaur
Dinosaur

Reputation: 55

windows-curses not working with an import error

I'm just doing some testing with windows-curses (2.3.0) and I was using this code and it gave me an error. The code and error are below.

Code:

import curses
from curses import wrapper

def main(stdscr):
    stdscr.clear()
    stdscr.addstr("Hello World")
    stdscr.refresh()
    stdscr.getch()

wrapper(main)

Error:

Traceback (most recent call last):
  File "C:\Users\norbe\OneDrive\Desktop\Projects\Testing\Curses\curses.py", line 1, in <module>
    import curses
  File "C:\Users\norbe\OneDrive\Desktop\Projects\Testing\Curses\curses.py", line 2, in <module>
    from curses import wrapper
ImportError: cannot import name 'wrapper' from partially initialized module 'curses' (most likely due to a circular import) 

Upvotes: 0

Views: 1194

Answers (2)

Aumansh
Aumansh

Reputation: 41

Apparently, If you name your file curses.py, it breaks it somehow! Make sure to change your file name to something else.

Upvotes: 4

S.A.H
S.A.H

Reputation: 36

The code already imported curses and its context (methods and variables) binded to it. It means that wrapper is already identified by python.

Try this :

import curses
wrapper = curses.wrapper

Upvotes: 0

Related Questions