import pwn 在 PyCharm 中崩溃,但在 运行 来自终端时有效
import pwn crashes in PyCharm, but works when run from terminal
当我尝试 运行 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
但是,当我从终端执行文件时,运行没问题。
我试图找到类似的问题,但似乎其他人的错误是 ImportError: cannot import name ENUM_P_TYPE
而不是我的错误。
我运行在 macOS 10.15.4 上安装这个。
问题是由于这个 Warning: _curses.error: setupterm: could not find terminfo database
,导致 curses 抛出错误和异常。
解决办法应该是导出终端变量
$ export TERM=linux
$ export TERMINFO=/bin/zsh
但对于pycharm,需要在pycharm的配置中完成。
基于this answer,应该从Edit Configurations -> Environment variables
开始设置,设置名称值对
TERM linux
TERMINFO /etc/zsh
当我尝试 运行 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
但是,当我从终端执行文件时,运行没问题。
我试图找到类似的问题,但似乎其他人的错误是 ImportError: cannot import name ENUM_P_TYPE
而不是我的错误。
我运行在 macOS 10.15.4 上安装这个。
问题是由于这个 Warning: _curses.error: setupterm: could not find terminfo database
,导致 curses 抛出错误和异常。
解决办法应该是导出终端变量
$ export TERM=linux
$ export TERMINFO=/bin/zsh
但对于pycharm,需要在pycharm的配置中完成。
基于this answer,应该从Edit Configurations -> Environment variables
开始设置,设置名称值对
TERM linux
TERMINFO /etc/zsh