Question

So I do have curses installed Ive checked it with dpkg. Now when I try to import it, this happens

Python 2.7.3 (default, Jan 13 2013, 11:20:46)
[GCC 4.6.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import curses
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "curses.py", line 3, in <module>
    myscreen = curses.initscr()
AttributeError: 'module' object has no attribute 'initscr'

I have no idea why it happens - I first tried to run this:

import curses

myscreen = curses.initscr()
myscreen.border(0)
myscreen.addstr(12, 25, "Python curses in action!")
myscreen.refresh()
myscreen.getch()

curses.endwin()

Since I tried it, this happens. Anyone got an idea?

Was it helpful?

Solution

Traceback (most recent call last):
    File "<stdin>", line 1, in <module>
    File "curses.py", line 3, in <module>

It seems you named your own file curses.py, Python looks in the current directory first so you cannot have the same name as a library.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top