Reputation: 11
I am using python 3.8.10 on Ubuntu 20.04 and successfully installed pyperclip. I wanted to run a basic test using this code:
import pyperclip
pyperclip.copy("testing")
pyperclip.paste()
At first, I was getting the error:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "c:\github\pyperclip\src\pyperclip\__init__.py", line 689, in waitForNewPaste
raise PyperclipTimeoutException('waitForNewPaste() timed out after ' + str(timeout) + ' seconds.')
pyperclip.PyperclipTimeoutException: waitForNewPaste() timed out after 5 seconds.
Tried installing xsel, PyQt5, and xclip and went from no error to it not printing or outputting anything. Has anyone had this issue in the past? What exactly is going on?
Apologies for the bad formatting of this question. I'm new here. I appreciate your patience.
Upvotes: 0
Views: 1899
Reputation: 501
This works for web and application fields.
import pyperclip
import keyboard
pyperclip.copy("testing")
keyboard.send('ctrl+v')
Upvotes: 0
Reputation: 1
yeah, the pyperclip.paste() will only work when you are IDLE/shell.
Upvotes: 0
Reputation: 11
Apologies,
I realized today that all we need is to wrap our paste() method in a print function:
import pyperclip
pyperclip.copy("testing")
print(pyperclip.paste())
Upvotes: 1