GD_Fever123
GD_Fever123

Reputation: 11

Pyperclip module not Printing from paste() method

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

Answers (3)

dave.zap
dave.zap

Reputation: 501

This works for web and application fields.

import pyperclip
import keyboard
pyperclip.copy("testing")
keyboard.send('ctrl+v')

Upvotes: 0

Salahuddin Jokhio
Salahuddin Jokhio

Reputation: 1

yeah, the pyperclip.paste() will only work when you are IDLE/shell.

Upvotes: 0

GD_Fever123
GD_Fever123

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

Related Questions