简体   繁体   English

import pwn 在 PyCharm 中崩溃,但在从终端运行时有效

[英]import pwn crashes in PyCharm, but works when run from terminal

When I try to run the line import pwn in PyCharm, it crashes with this error message:当我尝试在 PyCharm 中运行import pwn行时,它会因以下错误消息而崩溃:

/usr/local/bin/python3.8 /Users/ianzhang/Documents/Coding/CTF/buffer_overflow1.py
Warning: _curses.error: setupterm: could not find terminfo database

Traceback (most recent call last):
  File "/Users/ianzhang/Documents/Coding/CTF/buffer_overflow1.py", line 1, in <module>
    import pwn
  File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/pwn/__init__.py", line 4, in <module>
    from pwn.toplevel import *
  File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/pwn/toplevel.py", line 20, in <module>
    import pwnlib
  File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/pwnlib/__init__.py", line 43, in <module>
    importlib.import_module('.%s' % module, 'pwnlib')
  File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/pwnlib/args.py", line 62, in <module>
    from pwnlib import term
  File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/pwnlib/term/__init__.py", line 6, in <module>
    from pwnlib.term import completer
  File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/pwnlib/term/completer.py", line 7, in <module>
    from pwnlib.term import readline
  File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/pwnlib/term/readline.py", line 13, in <module>
    from pwnlib.term import text
  File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/pwnlib/term/text.py", line 126, in <module>
    sys.modules[__name__] = Module()
  File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/pwnlib/term/text.py", line 49, in __init__
    s = termcap.get(y)
  File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/pwnlib/term/unix_termcap.py", line 28, in get
    s = curses.tigetstr(cap)
_curses.error: must call (at least) setupterm() first

Process finished with exit code 1

However, when I execute the file from the terminal, it runs fine.但是,当我从终端执行文件时,它运行良好。

I have tried to find similar questions, but it seems that other people have the error ImportError: cannot import name ENUM_P_TYPE rather than the error that I have.我试图找到类似的问题,但似乎其他人有错误ImportError: cannot import name ENUM_P_TYPE而不是我的错误。

I am running this on macOS 10.15.4.我在 macOS 10.15.4 上运行它。

The issue is due to this, Warning: _curses.error: setupterm: could not find terminfo database , leading to the curses throwing error and exception.问题是由于这个, Warning: _curses.error: setupterm: could not find terminfo database ,导致curses抛出错误和异常。

The solution should be to export the terminal variables解决方案应该是导出终端变量

$ export TERM=linux
$ export TERMINFO=/bin/zsh

But for pycharm, it needs to be done inside pycharm's configuration.但是对于pycharm,需要在pycharm的配置里面完成。

Based on this answer , it should be set from Edit Configurations -> Environment variables and set the name value pairs.根据这个答案,应该从Edit Configurations -> Environment variables设置它并设置名称值对。

TERM linux

TERMINFO /etc/zsh

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 导入语句适用于 PyCharm 但不适用于终端 - Import statement works on PyCharm but not from terminal 从终端运行脚本时无法导入 tensorflow,即使 tensorflow 在 jupyter 笔记本和终端中工作 - Can't import tensorflow when run script from terminal, even though tensorflow works in jupyter notebook and terminal Python 可以在 PyCharm 中运行,但不能在终端中运行 - Python works in PyCharm but not from terminal 遇到终端导入错误,但是PyCharm可以运行 - Meet import error in terminal, but PyCharm can run it 程序在IDE(Pycharm)上运行时可以运行,但在终端上运行时却不能运行? - Program works when I run it on the IDE (Pycharm) but not when I run it on the terminal? Pycharm 导入时调试失败,但运行有效 - Pycharm Debug fails on import, but Run works 在 pycharm 中运行 python 有效,但不能从终端运行 - Running python inside pycharm works, but not from terminal 导入模块在 PyCharm 中工作,但在终端 python 3.7 中出错 - Import module works in PyCharm but giving error in terminal python 3.7 如何使用 pycharm 环境从终端运行 a.py - How to run a .py from terminal with a pycharm environnement 从子进程读取的实时stdout仅在从PyCharm运行而不在Terminal运行时有效 - Real-time stdout read from subprocess works only when running from PyCharm and not Terminal
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM