所以我确实安装了curses我已经用dpkg检查了它。 现在,当我尝试导入它时,会发生这种情况
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'
我不知道为什么会这样 - 我第一次试图运行它:
import curses
myscreen = curses.initscr()
myscreen.border(0)
myscreen.addstr(12, 25, "Python curses in action!")
myscreen.refresh()
myscreen.getch()
curses.endwin()
自从我尝试过,就会发生这种情况。有人有想法吗?
答案 0 :(得分:9)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "curses.py", line 3, in <module>
您似乎将自己的文件命名为curses.py, Python首先在当前目录中查找,因此您不能与库具有相同的名称。