Python _curses.error: setupterm: could not find terminfo database

I'm receiving the following error while attempting to debug/run a curses based Python script on OS X 10.8.2, IDEA Ultimate 11.1.3, Python plugin 2.9.2, and Python SDK 2.7.2.  I can execute the script from a terminal session without any problem.  Is there a workaround for this issue to allow debugging within IDEA?

pydev debugger: starting
Traceback (most recent call last):
  File "/Users/jamesallman/Library/Application Support/IntelliJIdea11/python/helpers/pydev/", line 1401, in <module>['file'], None, None)
  File "/Users/jamesallman/Library/Application Support/IntelliJIdea11/python/helpers/pydev/", line 1055, in run
    pydev_imports.execfile(file, globals, locals) #execute the script
  File "/Users/jamesallman/IdeaProjects/python/menu/", line 36, in <module>
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/curses/", line 22, in wrapper
    stdscr = curses.initscr()
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/curses/", line 33, in initscr
_curses.error: setupterm: could not find terminfo database

Here is the basic code to cause the error:

import curses

from curses.wrapper import wrapper

def main(scr):
    c = scr.getch()


Comment actions Permalink

Most likely the TERMINFO environment variable, which specifies the path to the terminfo database, is set in your .bash_profile file or in another file which is not visible to PyCharm when you run it from a desktop shortcut. The easiest workaround is to define the TERMINFO environment variable in the run configuration settings in PyCharm.

Comment actions Permalink

Any resolution to this problem yet? I am using iPython with PyPy inside a project created by virtualenv on my mac at "/Users/admin/web_projects/apps/blog".

Following is the traceback I get when I try to launch the Python console from 'Run' in PyCharm 2.5.1:

/Users/admin/web_projects/apps/blog/bin/pypy -u /Applications/ 50513 50514

PyDev console: using IPython 0.13.2

Traceback (most recent call last):

  File "", line 72, in run_toplevel

  File "/Applications/", line 361, in <module>

    StartServer(pydev_localhost.get_localhost(), int(port), int(client_port))

  File "/Applications/", line 288, in StartServer

    interpreter = InterpreterInterface(host, client_port, threading.currentThread())

  File "/Applications/", line 37, in __init__

    self.interpreter = PyDevFrontEnd()

  File "/Applications/", line 35, in __init__

    shell = TerminalInteractiveShell.instance()

  File "/Users/admin/web_projects/apps/blog/site-packages/IPython/config/", line 318, in instance

    inst = cls(*args, **kwargs)

  File "/Users/admin/web_projects/apps/blog/site-packages/IPython/frontend/terminal/", line 360, in __init__

    user_module=user_module, custom_exceptions=custom_exceptions

  File "/Users/admin/web_projects/apps/blog/site-packages/IPython/core/", line 454, in __init__


  File "/Users/admin/web_projects/apps/blog/site-packages/IPython/core/", line 1843, in init_readline


  File "/Users/admin/web_projects/apps/blog/site-packages/IPython/core/", line 1851, in refill_readline_hist


  File "/tmp/python_packages/pypy-2.0.2/lib_pypy/pyrepl/", line 284, in clear_history

    del self.get_reader().history[:]

  File "/tmp/python_packages/pypy-2.0.2/lib_pypy/pyrepl/", line 188, in get_reader

    console = UnixConsole(self.f_in, self.f_out, encoding=ENCODING)

  File "/tmp/python_packages/pypy-2.0.2/lib_pypy/pyrepl/", line 98, in __init__

    curses.setupterm(term, self.output_fd)

error: setupterm: could not find terminfo database

Process finished with exit code 1

Couldn't connect to console process.

So, it did detect the iPython in the bin directory. How and where do I set the TERMINFO env variable and what do I set it to ?

Comment actions Permalink

This still doesn't work -- OS X. I've edited the run/debug configuration to set environment variables TERM to xterm-256colors, and TERMINFO=/usr/share/terminfo. I no longer get "could not find terminfo database", but instead I get "_curses.error: cbreak() returned ERR", "During handling of the above exception, another exception occurred: .......... _curses.error: nocbreak() returned ERR". after calling curses.wrapper(my_callable).

Is it possible to run and debug a Python curses app/script in PyCharm? or does one have to remote-debug it?


Please sign in to leave a comment.