pandas-dev / pandas

Flexible and powerful data analysis / manipulation library for Python, providing labeled data structures similar to R data.frame objects, statistical functions, and much more
https://pandas.pydata.org
BSD 3-Clause "New" or "Revised" License
43.73k stars 17.95k forks source link

to_clipboard has no effect in ipython (works in python) (linux) #22707

Closed seanv507 closed 4 years ago

seanv507 commented 6 years ago

Code Sample, a copy-pastable example if possible

# Your code here
import pandas as pd
a=pd.DataFrame([0,1,23])
a.to_clipboard()

Problem description

Hi since several months I am no longer able to use the to_clipboard function in ipython - nothing pasted to clipboard. I notice it works in python!!. I have tried using latest version of ipython/pandas on anaconda but no improvement

Expected Output

I expect to paste dataframe into text file etc.

Output of pd.show_versions()

INSTALLED VERSIONS ------------------ commit: None python: 3.6.3.final.0 python-bits: 64 OS: Linux OS-release: 4.15.0-34-generic machine: x86_64 processor: x86_64 byteorder: little LC_ALL: None LANG: en_GB.UTF-8 LOCALE: en_GB.UTF-8 pandas: 0.23.4 pytest: 3.7.2 pip: 9.0.3 setuptools: 40.2.0 Cython: 0.26.1 numpy: 1.13.3 scipy: 1.0.0 pyarrow: 0.7.1 xarray: None IPython: 6.5.0 sphinx: 1.6.3 patsy: 0.4.1 dateutil: 2.7.3 pytz: 2014.10 blosc: None bottleneck: 1.2.1 tables: 3.4.2 numexpr: 2.6.2 feather: None matplotlib: 2.1.0 openpyxl: 2.4.8 xlrd: 1.1.0 xlwt: 1.3.0 xlsxwriter: 1.0.2 lxml: 4.1.0 bs4: 4.4.1 html5lib: 0.9999999 sqlalchemy: 1.0.14 pymysql: None psycopg2: 2.7.1 (dt dec pq3 ext lo64) jinja2: 2.7.3 s3fs: None fastparquet: None pandas_gbq: None pandas_datareader: None
TomAugspurger commented 6 years ago

http://pandas-docs.github.io/pandas-docs-travis/io.html#clipboard

Note

You may need to install xclip or xsel (with gtk, PyQt5, PyQt4 or qtpy) on Linux to use these methods.

Do you have those installed/

seanv507 commented 6 years ago

well I installed xsel, and it still didn't work. [and note it works in normal python just not ipython?]. (and it used to work on my linux machine??)

TomAugspurger commented 6 years ago

Is your ipython the same environment as your python? (output of which ipython and which python).

On Fri, Sep 14, 2018 at 7:06 AM seanv507 notifications@github.com wrote:

well I installed xsel, and it still didn't work. [and note it works in normal python just not ipython?]. (and it used to work on my linux machine??)

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/pandas-dev/pandas/issues/22707#issuecomment-421338301, or mute the thread https://github.com/notifications/unsubscribe-auth/ABQHIq_vKV7tYnx5PHniDgHUtJqlm9Jqks5ua5vWgaJpZM4Wox5T .

seanv507 commented 6 years ago

thanks - yes it is just root anaconda folder

TomAugspurger commented 6 years ago

Any luck debugging this @seanv507?

seanv507 commented 6 years ago

not so far. I don' know where to look [ I know it must be something to do with my config]. my workaround currently is pyperclip.copy(df.to_csv())

On Tue, Sep 18, 2018 at 5:09 PM Tom Augspurger notifications@github.com wrote:

Any luck debugging this @seanv507 https://github.com/seanv507?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/pandas-dev/pandas/issues/22707#issuecomment-422431727, or mute the thread https://github.com/notifications/unsubscribe-auth/ADJxL04nU3gbs9ae8EYw5fI75j7W07Knks5ucQy1gaJpZM4Wox5T .

moinluk commented 5 years ago

The to_clipboard function is still not working properly with ipython or jupyter, but it works with python. The example code above results in following error:

QXcbClipboard::setMimeData: Cannot set X11 selection owner

It seems that in my case the qt_clipboard was used. Is there a possibility to switch to a another clipboard e.g. xclip or xsel (pyperclip works fine)?

Output of pd.show_versions()

INSTALLED VERSIONS ------------------ commit: None python: 3.7.0.final.0 python-bits: 64 OS: Linux OS-release: 4.15.0-43-generic machine: x86_64 processor: x86_64 byteorder: little LC_ALL: None LANG: de_DE.UTF-8 LOCALE: de_DE.UTF-8 pandas: 0.23.4 pytest: 3.8.0 pip: 18.1 setuptools: 40.2.0 Cython: 0.28.5 numpy: 1.15.1 scipy: 1.1.0 pyarrow: None xarray: None IPython: 6.5.0 sphinx: 1.8.2 patsy: 0.5.0 dateutil: 2.7.3 pytz: 2018.5 blosc: None bottleneck: 1.2.1 tables: 3.4.4 numexpr: 2.6.8 feather: None matplotlib: 2.2.3 openpyxl: 2.5.6 xlrd: 1.1.0 xlwt: 1.3.0 xlsxwriter: 1.1.0 lxml: 4.2.5 bs4: 4.6.3 html5lib: 1.0.1 sqlalchemy: 1.2.11 pymysql: None psycopg2: None jinja2: 2.10 s3fs: None fastparquet: None pandas_gbq: None pandas_datareader: None
TomAugspurger commented 4 years ago

It's possible that the recenlty updated pyperclip we vendor has fixed some issues.

Is there a possibility to switch to a another clipboard e.g. xclip or xsel (pyperclip works fine)?

Not really, aside from manually setting pandas.io.clipboard.copy and pandas.io.clipboard.paste.

Going to close this since this is isn't easily reproducible so it's not clear what needs to be done.

moinluk commented 4 years ago

It seems be fixed in pd.version = '0.26.0.dev0+1487.g733eb77f7' Thanks.

filiphl commented 3 years ago

Installing xclip fixed this for me.

mattmoehr commented 3 years ago

Same for me. Needed to sudo apt install xclip.

Ubuntu 20.04 pandas 1.2.4