Sheldan
Sheldan

Reputation: 73

Pyperclip does not persist if script exits

I want to store something into the clipboard via a python script.

It's basically just pyperclip.copy('text'). I'm using Fedora 21 with AwesomeWM. I read here that a clipboard manager is needed to store it permanent in the clipboard. I installed parcellite. It now works, if I use it in an terminal, via

$python
$>>> import pyperclip
$>>> pyperclip.copy('teststring')

BUT if I do the exact same thing in an script

import pyperclip
pyperclip.copy('teststring')

and execute this script with python filename.

It won't get stored in the clipboard.

Upvotes: 1

Views: 187

Answers (1)

aless80
aless80

Reputation: 3332

It works for me with pyperclip-1.5.27. With this script, test.py:

import pyperclip
pyperclip.copy('The text to be copied to the clipboard.')

$>python ./test.py

Then doing Ctrl+V pastes:

The text to be copied to the clipboard.

Are you sure pyperclip.copy is running or is your script more complex than that?

Upvotes: 1

Related Questions