Skip to main content

PyClipX

Cross-platform clipboard utilities supporting both binary and text data.

This is a fork of the original PyClip project, maintained under Apache License 2.0. All functionality remains compatible with the original API.

Why PyClipX?

This fork was created to fix clipboard compatibility issues when running with sudo on Ubuntu 26.04 LTS and other modern Linux distributions that use pure Wayland as the display server. While the original PyClip project works fine in non-root environments, it encounters issues when run with elevated privileges. This version focuses on:

  • Sudo compatibility - fixes clipboard operations when running with sudo privileges on Wayland
  • Enhanced Wayland support through the wayland_clip.py module, which provides clipboard functionality via wl-copy/wl-paste commands
  • Modern Linux compatibility for systems that have moved away from X11 to Wayland

The wayland_clip.py module specifically handles clipboard operations on Wayland by leveraging the wl-clipboard package, which is the standard Wayland clipboard utility.

PyPI Version Python Versions

Some key features include:

  • A cross-platform API (supports MacOS, Windows, Linux)
  • Can handle arbitrary binary data
  • On Windows, some additional clipboard formats are supported

Installation

Requires python 3.7+

pip install pyclipx

Usage

pyclip can be used in Python code

import pyclip

pyclip.copy("hello clipboard") # copy data to the clipboard
cb_data = pyclip.paste() # retrieve clipboard contents 
print(cb_data)  # b'hello clipboard'
cb_text = pyclip.paste(text=True)  # paste as text
print(cb_text)  # 'hello clipboard'

pyclip.clear() # clears the clipboard contents
assert not pyclip.paste()

Note: When running with sudo on Wayland (e.g., Ubuntu 26.04 LTS), pyclipx automatically detects the sudo environment and sets the necessary Wayland environment variables (WAYLAND_DISPLAY and XDG_RUNTIME_DIR) for you. No manual configuration is needed.

Or a CLI

# paste clipboard contents to stdout
python -m pyclip paste

# load contents to the clipboard from stdin
python -m pyclip copy < myfile.text
# same as above, but pipe from another command
some-program | python -m pyclip copy

Installing via pip also provides the console script pyclip:

pyclip copy < my_file.txt

This library implements functionality for several platforms and clipboard utilities.

  • MacOS
  • Windows
  • Linux on x11 (with xclip)
  • Linux on wayland (with wl-clipboard)

If there is a platform or utility not currently listed, please request it by creating an issue.

Platform specific notes/issues

Windows

  • On Windows, the pywin32 package is installed as a requirement.
  • On Windows, additional clipboard formats are supported, including copying from a file (like if you right-click copy from File Explorer)

MacOS

MacOS has support for multiple backends. By default, the pasteboard package is used.

pbcopy/pbpaste can also be used as a backend, but does not support arbitrary binary data, which may lead to data being lost on copy/paste. This backend may be removed in a future release.

Linux

Linux on X11 requires xclip to work. Install with your package manager, e.g. sudo apt install xclip Linux on Wayland requires wl-clipboard to work. Install with your package manager, e.g. sudo apt install wl-clipboard

Acknowledgements

Big thanks to Howard Mao for donating the PyClip project name on PyPI to the original project.

Metadata

Release files for pyclipx 0.8.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pyclipx 0.8.0
File Size Uploaded
pyclipx-0.8.0.tar.gz 16.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for pyclipx 0.8.0
File Interpreter ABI Platform
pyclipx-0.8.0-py3-none-any.whl Python 3 none any Details

Total release size: 36.6 kB

Release files / pyclipx-0.8.0.tar.gz

Download URL pyclipx-0.8.0.tar.gz
Size 16.9 kB
Tags Source
SHA-256 checksum
How to use checksums
0f0b9ff7c01a765615002c079798472cf895c78bf5d28ac2178c62615124314f
BLAKE2b-256 checksum
How to use checksums
f80d6433af8629183b348eb6c8cd3465bfcd76ef2a049dec7d113d879327d965
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.12

Release files / pyclipx-0.8.0-py3-none-any.whl

Download URL pyclipx-0.8.0-py3-none-any.whl
Size 19.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
b9adf4d5742a05c624a2a90a0155af43b4aa58c8a5033484326c3939f95cee8e
BLAKE2b-256 checksum
How to use checksums
21379e0dc5f8905b52c6eed957034551898d774aa41dcfe5907d3c66f2992b90
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.12

Release history Release notifications | RSS feed

This release

0.8.0 This release

2 release files

0.7.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page