【发布时间】:2020-12-11 19:24:35
【问题描述】:
我正在通过 Windows 10 build 20190 上的 Windows Terminal Preview (1.2.2234.0) 在 WSL2 中运行的 Ubuntu 18.04 上使用 IPython 7.16.1 (Python 3.7.7)(尽管问题不仅限于 IPython,它与壳本身)。我正在尝试对从 Windows 复制的数据使用 pandas.read_clipboard(),即在 WSL 之外。但是,得到以下错误:
PyperclipException:
Pyperclip could not find a copy/paste mechanism for your system.
For more information, please visit
https://pyperclip.readthedocs.io/en/latest/introduction.html#not-implemented-error
我明白这是因为 WSL 不支持显示,但是,由于我可以在 WSL 和 Windows 之间复制粘贴数据,因此应该有一种机制可以访问 Windows 剪贴板。有解决办法吗?
我按照建议的here 和here 看过xclip、xsel、QTpy,但没有帮助。
完整的堆栈跟踪:
In [1]: import pandas as pd
In [2]: df = pd.read_clipboard()
---------------------------------------------------------------------------
PyperclipException Traceback (most recent call last)
<ipython-input-2-861af318b71b> in <module>
----> 1 df = pd.read_clipboard()
~/anaconda3/envs/tensorflow_gpu/lib/python3.7/site-packages/pandas/io/clipboards.py in read_clipboard(sep, **kwargs)
36 from pandas.io.parsers import read_csv
37
---> 38 text = clipboard_get()
39
40 # Try to decode (if needed, as "text" might already be a string here).
~/anaconda3/envs/tensorflow_gpu/lib/python3.7/site-packages/pandas/io/clipboard/__init__.py in lazy_load_stub_paste()
648 global copy, paste
649 copy, paste = determine_clipboard()
--> 650 return paste()
651
652
~/anaconda3/envs/tensorflow_gpu/lib/python3.7/site-packages/pandas/io/clipboard/__init__.py in __call__(self, *args, **kwargs)
285 class ClipboardUnavailable:
286 def __call__(self, *args, **kwargs):
--> 287 raise PyperclipException(EXCEPT_MSG)
288
289 def __bool__(self) -> bool:
PyperclipException:
Pyperclip could not find a copy/paste mechanism for your system.
For more information, please visit
https://pyperclip.readthedocs.io/en/latest/introduction.html#not-implemented-error
【问题讨论】:
-
请勿发布代码、数据、错误消息等的图片 - 将文本复制或输入到问题中。 How to Ask
-
@Rob 没有要发布的数据,我的代码是
pandas.read_clipboard(),我已经指定了。如果您需要文本中的堆栈跟踪,我可以添加它,但看不出有什么帮助。 -
@SayandipDutta 他的意思是堆栈跟踪。作为文本而不是图像更容易阅读和使用,通常不使用图像来表示任何类型的文本是一种好习惯。
标签: python ubuntu windows-subsystem-for-linux pyperclip windows-terminal