Visidata: "could not find terminal" in pycharm python console when using vd.view_pandas(df)

Created on 23 Jul 2020  路  9Comments  路  Source: saulpw/visidata

Small description

love the vd.view_pandas(df) functionality and works perfectly in iPython, however there seems to be a slight incompatibility with the pycharm python console.

Actual result with screenshot

import visidata as vd
vd.view_pandas(df)
Traceback (most recent call last):
  File "/home/me/.local/share/virtualenvs/code-gCh16mu5/lib/python3.8/site-packages/IPython/core/interactiveshell.py", line 3343, in run_code
    exec(code_obj, self.user_global_ns, self.user_ns)
  File "<ipython-input-75-839e95a99395>", line 1, in <module>
    vd.view_pandas(df_filtered)
  File "/home/me/.local/share/virtualenvs/code-gCh16mu5/lib/python3.8/site-packages/visidata/loaders/_pandas.py", line 44, in view_pandas
    run(PandasSheet('', source=df))
  File "/home/me/.local/share/virtualenvs/code-gCh16mu5/lib/python3.8/site-packages/visidata/vdtui.py", line 2841, in run
    ret = wrapper(cursesMain, sheetlist)
  File "/home/me/.local/share/virtualenvs/code-gCh16mu5/lib/python3.8/site-packages/visidata/vdtui.py", line 2831, in wrapper
    return curses.wrapper(setupcolors, f, *args)
  File "/home/me/.pyenv/versions/3.8.3/lib/python3.8/curses/__init__.py", line 84, in wrapper
    stdscr = initscr()
  File "/home/me/.pyenv/versions/3.8.3/lib/python3.8/curses/__init__.py", line 29, in initscr
    setupterm(term=_os.environ.get("TERM", "unknown"),
_curses.error: setupterm: could not find terminal

Additional context

  • The "use iPython when available" box is checked in Settings > Build, Execution, Deployment > Console panel.
  • Information provided by the pycharm python console at the very top when you open it:
Python 3.8.3 (default, Jun 24 2020, 18:02:19) 
Type 'copyright', 'credits' or 'license' for more information
IPython 7.16.1 -- An enhanced Interactive Python. Type '?' for help.
PyDev console: using IPython 7.16.1
  • vd version: 1.5.2

Any tips on how to solve would be appreciated!

bug

All 9 comments

Hi @manihamidi, I don't have a pycharm setup so it's going to be difficult to debug given only this information. Is this on Windows?

It seems like this is more related to how PyCharm interfaces with curses, than with VisiData specifically!

Some potentially helpful things to try are here: https://stackoverflow.com/questions/9485699/setupterm-could-not-find-terminal-in-python-program-using-curses

hey @saulpw , no i'm running pycharm on ubuntu 18. I'm getting by using the pycharm terminal to run ipython and then visidata. It's not ideal but ok for now..

thanks for the link @anjakefala . Tried setting the envvar and now i get a different error!

Traceback (most recent call last):
  File "/home/me/.pyenv/versions/3.8.3/lib/python3.8/curses/__init__.py", line 89, in wrapper
    cbreak()
_curses.error: cbreak() returned ERR
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
  File "/home/me/.local/share/virtualenvs/code-gCh16mu5/lib/python3.8/site-packages/IPython/core/interactiveshell.py", line 3343, in run_code
    exec(code_obj, self.user_global_ns, self.user_ns)
  File "<ipython-input-6-839e95a99395>", line 1, in <module>
    vd.view_pandas(df_filtered)
  File "/home/me/.local/share/virtualenvs/code-gCh16mu5/lib/python3.8/site-packages/visidata/loaders/_pandas.py", line 44, in view_pandas
    run(PandasSheet('', source=df))
  File "/home/me/.local/share/virtualenvs/code-gCh16mu5/lib/python3.8/site-packages/visidata/vdtui.py", line 2841, in run
    ret = wrapper(cursesMain, sheetlist)
  File "/home/me/.local/share/virtualenvs/code-gCh16mu5/lib/python3.8/site-packages/visidata/vdtui.py", line 2831, in wrapper
    return curses.wrapper(setupcolors, f, *args)
  File "/home/me/.pyenv/versions/3.8.3/lib/python3.8/curses/__init__.py", line 111, in wrapper
    nocbreak()
_curses.error: nocbreak() returned ERR

which seems to be addressed here: https://stackoverflow.com/questions/52747655/why-do-i-get-curses-error-cbreak-returned-err-when-using-tensorflow-cli-de

Not sure how that solution translates to curses/vd.. any ideas?

cbreak would return ERR if you run a curses application that is not on a real terminal

Did you follow these steps?

hit menu Run then Edit configurations...
select the configuration corresponding to your project
check the checkbox Emulate terminal in output console

I basically have no idea, and I am also using google to find these things. =( I hope you figure it out!

I am going to close this issue because I do not think the problem is on our end, but please continue using it as a space to debug your problems with us. It may help somebody else who faces a similar issue down the line.

cbreak would return ERR if you run a curses application that is not on a real terminal

Did you follow these steps?

hit menu Run then Edit configurations...
select the configuration corresponding to your project
check the checkbox Emulate terminal in output console

I basically have no idea, and I am also using google to find these things. =( I hope you figure it out!

hmm... thanks that's potentially helpful, but those configurations are for python consoles that launch when you "run" a particular python module, not the interactive (iPython) console. Couldn't find a similar checkbox for the interactive console yet.

anyways thanks... submitted a ticket to pycharm, hopefully that'll help resolve the issue.

FYI for future readers: PyCharm support said:

Unfortunately, PyCharm doesn't support curses at the moment. Please feel free to submit a feature request about it to our issue tracker using the link https://youtrack.jetbrains.com/issues/PY

You can up-vote the feature request here: https://youtrack.jetbrains.com/issue/PY-43660

Thanks for checking back in!

Was this page helpful?
0 / 5 - 0 ratings