Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

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

rahulporuri opened this issue Oct 7, 2016 · 0 comments
Labels
IO Data IO issues that don't fit into a more specific label
Milestone

Comments

@rahulporuri
Copy link

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 jreback added the IO Data IO issues that don't fit into a more specific label label Oct 7, 2016
pankajp added a commit to pankajp/pandas that referenced this issue Dec 7, 2016
Fixes pandas-dev#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.

```
@jreback jreback added this to the 0.20.0 milestone Jan 21, 2017
AnkurDedania pushed a commit to AnkurDedania/pandas that referenced this issue Mar 21, 2017
closes pandas-dev#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 <[email protected]>

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

40d70f9 [Pankaj Pandey] BUG: Fix linux clipboard QApplication() creation
mattip pushed a commit to mattip/pandas that referenced this issue Apr 3, 2017
closes pandas-dev#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 <[email protected]>

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

40d70f9 [Pankaj Pandey] BUG: Fix linux clipboard QApplication() creation
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
IO Data IO issues that don't fit into a more specific label
Projects
None yet
2 participants