读取剪贴板在 jupyter 或终端中不起作用

Read clipboard not working in jupyter or terminal

我正在学习 pandas,但我被这个 read_clipboard 问题困住了。

nfl_frame = pd.read_clipboard()

这是我得到的错误

    AttributeError                            Traceback (most recent call last)
<ipython-input-30-cab596b16d61> in <module>()
----> 1 nfl = pd.read_clipboard()

/home/aditya/anaconda3/lib/python3.5/site-packages/pandas/io/clipboard.py in read_clipboard(**kwargs)
     18     from pandas.io.parsers import read_table
     19     text = clipboard_get()
---> 20     text = text.decode('UTF-8')
     21 
     22     # try to decode (if needed on PY3)

AttributeError: 'str' object has no attribute 'decode'

clipboard.py 文件的一部分

from pandas.util.clipboard import clipboard_get
from pandas.io.parsers import read_table
text = clipboard_get()
text = text.decode('UTF-8')

异常错误消息告诉您需要安装一些额外的帮助软件:

"Pyperclip requires the gtk, PyQt4, or PySide module installed, or either the xclip or xsel command"

您可以安装其中任何一个以使其正常工作。当您在 Ubuntu 上开发时,最简单的方法可能是安装 xclipxsel:

sudo apt-get install xclip