至于你能做些什么……好吧,这取决于你最初尝试使用 pyperclip 的原因.在无头系统上,无处可复制数据,也无可粘贴数据,因此它并不是特别有用.例如,如果您要在同一台计算机上的两个不同的Python脚本之间共享数据,那么比通过剪贴板传递数据更简单的方法-只需使用文件,管道,套接字,等等-甚至都不需要具有复杂设置的第三方库.Specs:Python3.5Latest PyperclipBoth xclip and python3-pyqt4 installedusing ssh(Putty) to connect to headleass raspberry pi 2 model B using Latest Raspian Stretch LightError: pyperclip.copy('Hello world!') File "/usr/local/lib/python3.5/dist-packages/pyperclip/__init__.py", line 612, in lazy_load_stub_copy return copy(text) File "/usr/local/lib/python3.5/dist-packages/pyperclip/__init__.py", line 297, in __call__ raise PyperclipException(EXCEPT_MSG)pyperclip.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-errorI have also tried uninstalling and reinstalling both the module and clipboard programs. ive searched for 2 hours looking for an answer and used all of them and they didn't work. I admit i am a noob but it SHOULD'NT be this hard for me to do this. 解决方案 The clipboard is part of your GUI. But you don't have a GUI. So there is no clipboard to copy and paste with. There is no clipboard for pyperclip to access, so it doesn't matter how you try to access it, you're going to fail.You can test very easily by running this at the shell:xclipIf it says something like Error: No display: (null), then that's your problem.If you think you should have a GUI, because you've set things up to, e.g., tunnel X11 through ssh to an X server on your desktop machine, but you're still getting an error from xclip, then the problem is that you've set things up wrong. The simplest thing to check is:echo $DISPLAYIs that empty? Then your session doesn't know anything about your X11 tunnel. Getting tunneling set up properly is really an issue for a site like Super User or Unix, not Stack Overflow—and, once you get that fixed, pyperclip, and your script, should just start working.As for what you can do about it… well, it depends on why you were trying to use pyperclip in the first place. On a headless system, there's nowhere to copy data from, and nowhere to paste it to, so it wouldn't be particularly useful.If you're trying to, e.g., share data between two different Python scripts on the same machine, then there are simpler ways to do that than passing it through a clipboard—just use a file, a pipe, a socket, etc.—that don't even require a third-party library with complicated setup. 这篇关于无法获取pyperclip以在python3上使用复制和粘贴模块的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云! 09-05 10:17