Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.
        """
        self.writeline("Parameters:")
        for item in params:
            self.writeline("\t%s" % item)
    def cmdTIME(self, params):
        """
        Print Time
        Added by dilbert
        """
        self.writeline(time.ctime())

logging.getLogger('').setLevel(logging.DEBUG)

tns = TNS(("0.0.0.0", 8023), TNH)
tns.serve_forever()

I get this error

Traceback (most recent call last):
File ".\telserv.py", line 1, in <module>
from telnetsrvlib import *
File "C:\Python27\lib\site-packages\telnetsrvlib-1.0.2-py2.4.egg\telnetsrvlib.py", line 31, in <module>
import curses.ascii
  File "C:\Python27\lib\curses\__init__.py", 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.

like image 503
Strommer Avatar asked Jul 01 '13 17:07

Strommer


3 Answers

You could also look into installing the curses module from here: http://www.lfd.uci.edu/~gohlke/pythonlibs/#curses.

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

like image 193
Johan Avatar answered Oct 17 '22 07:10

Johan


Install the UniCurses module from here: https://pypi.python.org/pypi/UniCurses

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.

like image 31
gorzek Avatar answered Oct 17 '22 06:10

gorzek


That works for me:

pip install windows-curses
like image 45
Yura G Avatar answered Oct 17 '22 07:10

Yura G