Pandas: printing Series in Jupyter/IPython opens and closes a terminal window

Created on 31 Oct 2016  路  6Comments  路  Source: pandas-dev/pandas

When Git for Windows is installed and the option to use Unix tools in the Windows command line is checked, printing a Series in Jupyter QTConsole or Notebook (or Jupyter consoles in IDEs like Spyder) causes a terminal window to quickly pop up and close. Sometimes this happens in other cases where the Series is not necessarily printed, and I have experienced many terminal windows popping up and closing one after the other.

import pandas as pd
pd.Series([1])

This seems to be due to series.py calling the get_terminal_size() function in terminal.py. That function states that it should only be used when running in a terminal and not in IPython GUIs, but series.py is calling it regardless. It then fails to find the terminal size and falls back to calling the tput command, which only exists in Windows if Cygwin/Git for Windows is installed, and causes a terminal window to be briefly opened.

Possibly related issue: http://stackoverflow.com/questions/36133447/pandas-printing-tput-unknown-terminal-emacs

Output of pd.show_versions()

INSTALLED VERSIONS

commit: None
python: 3.5.1.final.0
python-bits: 64
OS: Windows
OS-release: 10
machine: AMD64
processor: Intel64 Family 6 Model 78 Stepping 3, GenuineIntel
byteorder: little
LC_ALL: None
LANG: None

pandas: 0.18.1
nose: 1.3.7
pip: 8.1.2
setuptools: 27.2.0
Cython: 0.24.1
numpy: 1.11.1
scipy: 0.18.1
statsmodels: 0.6.1
xarray: None
IPython: 5.1.0
sphinx: 1.3.1
patsy: 0.4.1
dateutil: 2.5.3
pytz: 2016.6.1
blosc: None
bottleneck: 1.1.0
tables: 3.2.2
numexpr: 2.6.1
matplotlib: 1.5.3
openpyxl: 2.3.2
xlrd: 1.0.0
xlwt: 1.1.2
xlsxwriter: 0.9.3
lxml: 3.6.4
bs4: 4.5.1
html5lib: None
httplib2: None
apiclient: None
sqlalchemy: 1.0.13
pymysql: None
psycopg2: None
jinja2: 2.8
boto: 2.42.0
pandas_datareader: None

Bug Output-Formatting good first issue

Most helpful comment

SOLVED: Update to pandas=0.20.3 or better!

All 6 comments

@allthedata Thanks for the report. Would you like to try to do a PR to fix this? It should be fairly simple to detect if we are in a terminal or not.

It can probably just use get_console_size (defined here https://github.com/pandas-dev/pandas/blob/04f6cde53126aafe55e883511b7e687a77ce80b0/pandas/formats/format.py#L2494) which already includes such a check.

@allthedata, @jorisvandenbossche thank you for figuring out the issue. I can confirm that replacing pandas.util.terminal.get_terminal_size() with pandas.formats.format.get_console_size() in series.py fixes the issue of cmd windows popping up due to tput.exe calls.

I am not a developer and also I wouldn't know how to write a test for this issue. Still, I'd be happy to submit a pull request (https://github.com/Foucl/pandas/commit/4fed3a51c6610b4071767e6c47e7fd1843722843) if you think that would be helpful.

@Foucl yeah don't worry about a test for this, would be tricky to do that. If you'd make the change and add a release note would be enough.

RESOLVED: Problem no longer there in Pandas 0.20.3

Original post:

FYI, I have the same issue with _Pandas 0.20.1_ on
Python 3.6.1
Anaconda 4.4.0 (64-bit)
IPython 5.3.0

Is there a fix for this? The notes above don't seem to work for me.

Output of pd.show_versions():

INSTALLED VERSIONS

commit: None
python: 3.6.1.final.0
python-bits: 64
OS: Windows
OS-release: 7
machine: AMD64
processor: Intel64 Family 6 Model 45 Stepping 7, GenuineIntel
byteorder: little
LC_ALL: None
LANG: en
LOCALE: None.None

pandas: 0.20.1
pytest: 3.0.7
pip: 9.0.1
setuptools: 27.2.0
Cython: 0.25.2
numpy: 1.12.1
scipy: 0.19.0
xarray: None
IPython: 5.3.0
sphinx: 1.5.6
patsy: 0.4.1
dateutil: 2.6.0
pytz: 2017.2
blosc: None
bottleneck: 1.2.1
tables: 3.2.2
numexpr: 2.6.2
feather: None
matplotlib: 2.0.2
openpyxl: 2.4.7
xlrd: 1.0.0
xlwt: 1.2.0
xlsxwriter: 0.9.6
lxml: 3.7.3
bs4: 4.6.0
html5lib: 0.999
sqlalchemy: 1.1.9
pymysql: None
psycopg2: None
jinja2: 2.9.6
s3fs: None
pandas_gbq: None
pandas_datareader: None

SOLVED: Update to pandas=0.20.3 or better!

Was this page helpful?
0 / 5 - 0 ratings