10

I'm facing a weird problem. Using Pycharm (please do not troll about this fact), I'm trying to launch a short app that uses ncurses to render some things on my term.

While I can launch the project in a simple term without any problem, launching it from Pycharm raise the following error :

File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/curses/__init__.py", line 33, in initscr
    fd=_sys.__stdout__.fileno())
error: setupterm: could not find terminal

Process finished with exit code 0 

As far as I can see, all is about terminal environment variables. Pycharm launch the project (Run or Debug) from its own instance of the terminal, and curses will not work with it. So, I am wondering how may I configure Pycharm to launch my project inside a regular terminal.

The project is using Python 2.7. Pycharm is in EAP version 129.258 (doesn't work with other versions, including stables)

Thanks for your attention.

K.

Koreth
  • 681
  • 5
  • 15
  • 1
    See http://stackoverflow.com/q/135688/104891 or try running PyCharm like this: `open -a /Applications/PyCharm.app/`. – CrazyCoder Jun 09 '13 at 10:08
  • 1
    I believe the problem is that PyCharm doesn't use a real terminal, hence you cannot do anything about it. Simply launch the programs from a real terminal. – Bakuriu Jun 09 '13 at 13:11
  • 1
    @Bakuriu Please, have a look to the entire question before you comment. As you can see, the question mention that the problem IS Pycharm not launching a real term, and the question also hints that I don't wanna just launch it from a regular terminal. Thanks for your attention, anyway :) – Koreth Jun 09 '13 at 15:06
  • 1
    @CrazyCoder Thanks for the hints ! "open -a" helps, Pycharm works a bit better even though the integrated terminal emulator is very poor at managing curses and has lack of some other capabilities. – Koreth Jun 09 '13 at 15:09
  • 1
    You can have better results with the built-in SSH terminal and localhost connection. – CrazyCoder Jun 09 '13 at 15:10
  • Yep. That's what I'm trying now. Sadly (and @Bakuriu was right on this point), it seems we cannot do anything else to ask Pycharm to launch a better console. Thanks, again. – Koreth Jun 09 '13 at 15:21
  • I don't use pycharm but it may work by running your app in a regular terminal through the remote debugger for debugging. – tdelaney Jun 09 '13 at 21:09

2 Answers2

7

I solved the curses debugging problem by attaching the debugger to a process.

  • Start the program in a terminal
  • Pycharm -> Tools -> Attach to Process
  • Select my prog
  • Done

Trying to attach as non-root requires additional ptrace access rights.

Explained here: http://blog.mellenthin.de/archives/2010/10/18/gdb-attach-fails-with-ptrace-operation-not-permitted/#comment-141535

On my ubuntu machine: echo 0 > /proc/sys/kernel/yama/ptrace_scope (as root)

respectively set ptrace_scope to 0 in /etc/sysctl.d/10-ptrace.conf

another_user
  • 71
  • 1
  • 2
-1
  • Start PyCharm and make sure that ncurses is listed in File->Settings->Project Interpreter->Python Interpreter;
  • if you have 2.7 and 3.x interpreters installed, make sure that correct one(supporting ncurses) is selected as default for the project from which you launch your application;

I more than sure that you have both 2.7 and 3.x installed on your machine - I had most of the issues with pycharm for case where both Python's branch were installed.