[英]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.