gpt4 book ai didi

python - : how-to launch for a standard terminal (to solve an issue with curses)

转载 作者:太空狗 更新时间:2023-10-29 20:27:35 24 4
gpt4 key购买 nike

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

虽然我可以在一个简单的术语中毫无问题地启动该项目,但从 Pycharm 启动它会引发以下错误:

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 以在常规终端内启动我的项目。

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

感谢您的关注。

K.

最佳答案

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

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

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

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

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

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

关于python - : how-to launch for a standard terminal (to solve an issue with curses),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17008372/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com