Bulgakov Mihail
Bulgakov Mihail

Reputation: 1

Pyperclip doesn't copy to the clipboard outside of shell

I used

pip install pyperclip

to install the package. when I use it in a script, eg.:

import pyperclip
pyperclip.copy('somestring')
pyperclip.paste()

it would return 'somestring'

my issue is that I wanna use it to paste elsewhere but the shell, it acts like there's nothing to paste. What could be wrong? (I use linux system)

Upvotes: 0

Views: 561

Answers (2)

John McKirdy
John McKirdy

Reputation: 1

I was having the same issue on a Windows computer, perhaps the module is not supported on other things besides the python IDE as pyperclip.paste() would not work on anything other than that. My workaround was to

import pyautogui

hover over the spot you want to paste. Then in the terminal or IDE use:

pyautogui.displayMousePosition()

to display your mouse's x and y coordinates, then use those coordinates with:

pyautogui.click(x, y)
pyautogui.hotkey('ctrl', 'v')

to literally ctrl+v.

Upvotes: 0

m0ni01
m0ni01

Reputation: 1

I am facing same issue try pip3 install may be it work for you if not use xclip. this is werid shell command

import subprocess


subprocess.call(["xclip","-o"])

Upvotes: 0

Related Questions