BUG : Check for and Use QApplication instance : clipboard #14372

Closed
rahulporuri opened this Issue Oct 7, 2016 · 0 comments

Comments

Projects
None yet
2 participants

reading data from clipboard fails on Linux because pandas doesn't check if there's already a QApplication running - https://github.com/pydata/pandas/blob/master/pandas/util/clipboard.py#L247

import pandas

pandas.read_clipboard()
---------------------------------------------------------------------------
RuntimeError                              Traceback (most recent call last)
<ipython-input-2-4c32fab697e6> in <module>()
----> 1 pandas.read_clipboard()

/home/rporuri/.canopy/envs/User/lib/python2.7/site-packages/pandas/io/clipboard.pyc in read_clipboard(**kwargs)
     15     parsed : DataFrame
     16     """
---> 17     from pandas.util.clipboard import clipboard_get
     18     from pandas.io.parsers import read_table
     19     text = clipboard_get()

/home/rporuri/.canopy/envs/User/lib/python2.7/site-packages/pandas/util/clipboard.py in <module>()
    245     elif qtBindingInstalled:
    246         _functions = 'PyQt4 module'  # for debugging
--> 247         app = QtGui.QApplication([])
    248         cb = QtGui.QApplication.clipboard()
    249         paste = _pasteQt

RuntimeError: A QApplication instance already exists. 

Output of pd.show_versions()

## INSTALLED VERSIONS

commit: None
python: 2.7.11.final.0
python-bits: 64
OS: Linux
OS-release: 4.4.0-31-generic
machine: x86_64
processor: x86_64
byteorder: little
LC_ALL: None
LANG: en_IN

pandas: 0.18.0
nose: 1.3.7
pip: 8.1.2
setuptools: 23.1.0
Cython: 0.24
numpy: 1.10.4
scipy: 0.17.1
statsmodels: 0.6.1
xarray: None
IPython: 4.1.2
sphinx: 1.4.1
patsy: 0.4.1
dateutil: 2.5.2
pytz: 2016.3
blosc: None
bottleneck: None
tables: 3.2.2
numexpr: 2.6.0
matplotlib: 1.5.1
openpyxl: 2.3.4
xlrd: None
xlwt: None
xlsxwriter: None
lxml: 3.6.0
bs4: 4.4.1
html5lib: 0.999
httplib2: None
apiclient: None
sqlalchemy: None
pymysql: None
psycopg2: None
jinja2: 2.8
boto: None

jreback added the Data IO label Oct 7, 2016

@pankajp pankajp added a commit to pankajp/pandas that referenced this issue Dec 7, 2016

@pankajp pankajp BUG: Fix linux clipboard QApplication() creation
Fixes #14372

A Qt application cannot instantiate multiple `QApplication` instances,
so we create a new `QApplication` only when the global
`QApplication.instance()` is None.

Failing sample:

```
from PyQt4.QtGui import QApplication
myapp = QApplication([])
from pandas.util.clipboard import clipboard_get  # <--- ERROR

  File "prefix/lib/python2.7/site-packages/pandas/util/clipboard.py", line 164, in <module>

    app = qt4.QtGui.QApplication([])

RuntimeError: A QApplication instance already exists.

```
40d70f9

jreback added this to the 0.20.0 milestone Jan 21, 2017

jreback closed this in b1e29db Mar 20, 2017

@AnkurDedania AnkurDedania added a commit to AnkurDedania/pandas that referenced this issue Mar 21, 2017

@pankajp @AnkurDedania pankajp + AnkurDedania BUG: Fix linux clipboard QApplication() creation
closes #14372

A Qt application cannot instantiate multiple
`QApplication` instances, so we create a new `QApplication` only when
the global `QApplication.instance()` is None.

Author: Pankaj Pandey <pankaj86@gmail.com>

Closes #14815 from pankajp/patch-2 and squashes the following commits:

40d70f9 [Pankaj Pandey] BUG: Fix linux clipboard QApplication() creation
5b75cf8

@mattip mattip added a commit to mattip/pandas that referenced this issue Apr 3, 2017

@pankajp @mattip pankajp + mattip BUG: Fix linux clipboard QApplication() creation
closes #14372

A Qt application cannot instantiate multiple
`QApplication` instances, so we create a new `QApplication` only when
the global `QApplication.instance()` is None.

Author: Pankaj Pandey <pankaj86@gmail.com>

Closes #14815 from pankajp/patch-2 and squashes the following commits:

40d70f9 [Pankaj Pandey] BUG: Fix linux clipboard QApplication() creation
277166d

@linebp linebp added a commit to linebp/pandas that referenced this issue Apr 17, 2017

@pankajp @linebp pankajp + linebp BUG: Fix linux clipboard QApplication() creation
closes #14372

A Qt application cannot instantiate multiple
`QApplication` instances, so we create a new `QApplication` only when
the global `QApplication.instance()` is None.

Author: Pankaj Pandey <pankaj86@gmail.com>

Closes #14815 from pankajp/patch-2 and squashes the following commits:

40d70f9 [Pankaj Pandey] BUG: Fix linux clipboard QApplication() creation
8ac87bd
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment