Error no module named curses

When I try to run the following code…

from telnetsrvlib import *

if __name__ == '__main__':
"Testing - Accept a single connection"
class TNS(SocketServer.TCPServer):
    allow_reuse_address = True

class TNH(TelnetHandler):
    def cmdECHO(self, params):
        """ [<arg> ...]
        Echo parameters
        Echo command line parameters back to user, one per line.
        for item in params:
            self.writeline("\t%s" % item)
    def cmdTIME(self, params):
        Print Time
        Added by dilbert


tns = TNS(("", 8023), TNH)

I get this error

Traceback (most recent call last):
File ".\", line 1, in <module>
from telnetsrvlib import *
File "C:\Python27\lib\site-packages\telnetsrvlib-1.0.2-py2.4.egg\", line 31, in <module>
import curses.ascii
  File "C:\Python27\lib\curses\", line 15, in <module>
from _curses import *

I am running python 2.7 and have imported the telnetsrvlib library and I am running the code on windows 7. Any help would be appreciated.

Enquirer: Strommer


Solution #1:

Install the UniCurses module from here:

You may need to alter some of your code in order to use it, as it provides the functionality of NCurses, not the vanilla curses library.

Unfortunately, no direct Python for Windows port of curses exists.

Respondent: gorzek

Solution #2:

You could also look into installing the curses module from here:

It allows python’s native curses to be used on Windows, so all your standard python curses code can be used.

Respondent: Johan

Solution #3:

That works for me:

pip install windows-curses
Respondent: Yura G

Solution #4:

Got the same error with Python 3.4 on Ubuntu 14.04 and here is how I fixed it.

My /usr/local/lib/python3.4/lib-dynload/ directory did not have the following files –

Got a copy of the latest Python 3.4.2 source.
Then (extracted &) compiled it:


Now the .so files I need were in build/lib.linux-i686-3.4/ and I copied them to /usr/local/lib/python3.4/lib-dynload/.

Respondent: YKB

Solution #5:

inspired by @YKB, I did this for Ubuntu 16.04 and Python3.5.2,

sudo apt-get install libncurses5-dev,

and then go to source code of Python, and make, two new files are created.

And then copy them to lib-dynload folder at where you installed your python.

Respondent: TonyTony

The answers/resolutions are collected from stackoverflow, are licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0 .

Leave a Reply

Your email address will not be published.