When I try to run the line import pwn
in PyCharm, it crashes with this error message:
/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.
I am running this on 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.
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.
Based on this answer, it should be set from Edit Configurations -> Environment variables
and set the name value pairs.
TERM linux
TERMINFO /etc/zsh