python curses远程调试pdevd错误在setupterm [英] python curses remote debugging pdevd error in setupterm

查看:445
本文介绍了python curses远程调试pdevd错误在setupterm的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

可以在PyCharm中远程调试诅咒程序吗?如何设置?

Is it possible to debug a curse program remotely in PyCharm? How to set it up?

我遵循PyCharm 4.0.8指令,将其添加到 EXAMPLE.py npyscreen-4.8.7

I followed the PyCharm 4.0.8 instruction, added this to the "EXAMPLE.py" from "npyscreen-4.8.7".

import pydevd
pydevd.settrace('localhost', port=8899, stdoutToServer=False, stderrToServer=True)

总是在 setupterm

$ PYTHONPATH=~/bin/pycharm-debug.egg python EXAMPLE.py
Traceback (most recent call last):
  File "EXAMPLE.py", line 34, in <module>
    App.run()
  File "/home/.../npyscreen-4.8.7/npyscreen/apNPSApplication.py", line 30, in run
    return npyssafewrapper.wrapper(self.__remove_argument_call_main)
  File "/home/.../npyscreen-4.8.7/npyscreen/npyssafewrapper.py", line 41, in wrapper
    wrapper_no_fork(call_function)
  File "/home/.../npyscreen-4.8.7/npyscreen/npyssafewrapper.py", line 83, in wrapper_no_fork
    _SCREEN = curses.initscr()
  File "/usr/lib64/python2.6/curses/__init__.py", line 33, in initscr
    fd=_sys.__stdout__.fileno())
_curses.error: setupterm: could not find terminal






问题是pydevd将环境TERM从xterm更改为emacs。这可以通过一点测试程序来验证。


The problem is that pydevd changed environment "TERM" from "xterm" to "emacs". This can be verified by a little test program.

import pydevd
pydevd.settrace('localhost', port=8899, stdoutToServer=False, stderrToServer=True)
import os as _os
import sys as _sys
import curses
print " my term: ", _os.environ.get("TERM", "unknown"), "\n"
print " my fd:   ", _sys.__stdout__.fileno(), "\n"
print "\n  ok  1  \n"
curses.setupterm(term=_os.environ.get("TERM", "unknown"),
#curses.setupterm(term='xterm',
                fd=_sys.__stdout__.fileno())
print "\n  ok  2  \n"




  • 如果删除两行 pdevd ,程序成功,打印出来的 TERM xterm

  • 如果将第一个参数更改为 setupterm term ='xterm',即使使用 pydevd 也可以成功。

    • If removing the two lines with "pdevd", the program succeeds. The "TERM" it prints out is "xterm".
    • If change the 1st argument to "setupterm" into "term='xterm'", even with "pydevd" it succeeds.
    • 我想问题是如何使用 pydevd 设置更正t TERM

      I guess the question is how to have "pydevd" setup the correct "TERM"?

      推荐答案

      这个各种提示指出了硬编码在pydevd中设置TERM导致我的这个顺序,这对我有用:

      This various hints pointing out the hardcoded setting of the TERM in pydevd led me to this sequence, which works for me:

      #
      # From the instructions in the PyCharm remote debug setup screen,
      # add this to your code before curses is initialised.
      #
      import pydevd
      pydevd.settrace('localhost', port=8899)
      #
      # And then to fixup the broken setting in pydevd...
      #
      os.environ['TERM'] = 'xterm'
      

      这篇关于python curses远程调试pdevd错误在setupterm的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆