Mohammad Azhar Khan aka MAK

Software Engineer. Loves Python. Knows Python, Flask, Django, Node.js, serverless,AWS lambda and many more.

 Access clipboard using python

30 Jun 2016 » python, python3

I’m doing this tutorial using Python 3.x, but the same can be done using Python 2.x


The following python script has following properties

  • requires pyperclip module to run
  • Copy to and from clipboard
  • Tested on Unix(MacOs and Ubuntu)
  • But should also work on windows

Try, test, run and then write your own And I forgot something, Hello everyone :-)

The required pyperclip can be installed as follows:

pip3 install pyperclip

or more specifically

python3 -m pip install pyperclip

The installation can checked on Unix in following way:

pip3 freeze|grep 'pyperclip'

or more specifically

python3 -m pip freeze|grep 'pyperclip'

The result will be something like:


Now here is a self explanatory sample code.

import pyperclip
c=input('Enter text you want to copy: ')
print('\n'+c+" is on your clip board now, press any key to paste it on stdoutput")