Pycharm:如何启动标准终端(解决诅咒问题)

Pycharm : how-to launch for a standard terminal (to solve an issue with curses)(Pycharm:如何启动标准终端(解决诅咒问题))

本文介绍了Pycharm:如何启动标准终端(解决诅咒问题)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我遇到了一个奇怪的问题.使用 Pycharm(请不要对这个事实进行攻击),我正在尝试启动一个简短的应用程序,它使用 ncurses 在我的任期内呈现一些东西.

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.

虽然我可以简单地启动项目而没有任何问题,但从 Pycharm 启动它会引发以下错误:

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 

据我所知,一切都与终端环境变量有关.Pycharm 从它自己的终端实例启动项目(运行或调试),curses 将无法使用它.所以,我想知道如何配置 Pycharm 以在常规终端中启动我的项目.

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.

该项目使用 Python 2.7.Pycharm 在 EAP 版本 129.258 中(不适用于其他版本,包括稳定版)

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

感谢您的关注.

K.

推荐答案

我通过将调试器附加到进程来解决了curses调试问题.

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

  • 在终端中启动程序
  • Pycharm -> 工具 -> 附加到进程
  • 选择我的程序
  • 完成

尝试以非 root 身份附加需要额外的 ptrace 访问权限.

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

在这里解释:http://blog.mellenthin.de/archives/2010/10/18/gdb-attach-fails-with-ptrace-operation-not-permitted/#comment-141535

在我的 ubuntu 机器上:回声 0 >/proc/sys/kernel/yama/ptrace_scope(作为根)

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

分别在/etc/sysctl.d/10-ptrace.conf中设置ptrace_scope为0

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

这篇关于Pycharm:如何启动标准终端(解决诅咒问题)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本文标题为:Pycharm:如何启动标准终端(解决诅咒问题)

基础教程推荐