Can I run a Python script from PopClip?

I’d like to pass a string using PopClip to a python script. Is this possible, if yes, how?


Absolutely! You’ll need to create “full” extension rather than a snippet though. Thankfully it’s quite easy. Just create a folder and make text file called Config.yaml in there — this is in the same format as snippets. Then add your python script. And name the folder with the extension .popclipext. Something like this:

 -- MyExt.popclipext
 |-- Config.yaml

Now your Config.yaml could be something like:

name: My Extension
shell script file:
script interpreter: python3

Finally to install or update your extension into PopClip for testing, double click the MyExt.popclipext folder in Finder.

For more details see

1 Like

Thanks for making this clear. Might I ask how to access the selected text within the python script? I tried to derive it form the other examples, but failed.

The text will be in an environment variable called POPCLIP_TEXT. I’m not a python programmer at all, and I haven’t verified this, but I think something like

text = os.environ[POPCLIP_TEXT]

ought to do it.

Other variables are available too, the full table is at:


import os
text = os.environ['POPCLIP_TEXT']

is working fine.

1 Like

That’s great. I’ve added a Python example to the docs — it’s probably the most popular scripting language, after all.

1 Like