I installed pyperclip (a clipboard utility) on Windows VM and somehow some of the functions are not working. I am trying to use the waitForPaste()
function as below:
import pyperclip as pyc
import os
pyc.waitForPaste()
However, this is producing the following error:
AttributeError Traceback (most recent call
last) Cell In\[18\], line 1 \----\> 1 pyc.waitForPaste()
AttributeError: module 'pyperclip' has no attribute 'waitForPaste
Strangely, if the following code works just fine! I was able to write this snippet:
pyc.copy('The text to be copied to the clipboard.')
pyc.paste()
Which produced:
'The text to be copied to the clipboard.'
I am not facing the same issue on MACOS, only in Windows.
A CTRL+F for "waitForPaste" in the pyperclip
source code suggests that the function no longer exists despite still being in the documentation; the only hits it gets are in the documentation. You have a few options if you still need this functionality:
waitForPaste()
was implemented at some time but later deleted; if you look back far enough in the history, you might be able to find a version that works.pyperclip
issues page, although there seems to be quite a bit of backlog there at the moment.pyperclip
is open-source and publicly editable; if you write a working implementation or find the original implementation in the history, you can create a pull request to add it to the official source.Of course, there might be a reason this feature was deleted; if that is the case, it's probably best to let sleeping dogs lie.
The pyperclip
docs contain the following code snippet and error message to demonstrate the timeout
argument in waitForPaste()
.
>>> import pyperclip
>>> pyperclip.waitForNewPaste(5)
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.
However, line 689 no longer exists in __init__.py
; the last line is 658, which seems to imply that this function once existed but has since been deleted.