Python Forum

Full Version: pyperclip stopped working
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I have been using pyperclip for some time, using Python 3.6.9 on Ubuntu 18.04 LTS. I have now moved to Python 3.12.3 on Ubuntu 24.04 LTS, and pyperclip has stopped working.
This works in the interpreter -
>>>import pyperclip
>>>pyperclip.copy('pyperclip test')
>>>pyperclip.paste()
>>>'pyperclip test'
but if I do Ctrl-V after the copy command, I get what I last put on the clipboard, not ‘pyperclip test’. And when I use it in real code, the clipboard (as examined by Ctrl-V) is empty.

I have checked that xsel, xclip and qtpy are installed on my system.
Anyone any ideas?
try upgrading:
pip install --upgrade pyperclip
looking at the package docs, it was last upgraded in 2024
(Apr-02-2025, 10:06 PM)Larz60+ Wrote: [ -> ]try upgrading:
pip install --upgrade pyperclip
looking at the package docs, it was last upgraded in 2024
It is already the latest version - I upgraded it when I moved the system last week.
then perhaps you should send an email to one of the maintainers
email addresses located here: https://pypi.org/project/paperclip/
(Apr-04-2025, 04:26 AM)Larz60+ Wrote: [ -> ]then perhaps you should send an email to one of the maintainers
email addresses located here: https://pypi.org/project/paperclip/

@Larz60+ this is different package, django-realted

this is pyperclip
And anyway it's better to post issue on their Github repo, rather than sending an e-mail
That is, if they indeed think there is bug/incompatibility with python 3.13
Do pip --version to see what version it install to.
If wrong use python -m pip install pyperclip

Now should use uv🚀,it makes all easier(will download Python version if not on OS) and faster.
Here a 10-sec test and pyperclip work for python 3.13.1
tom@tom-VirtualBox:~/test_env$ uv venv --python 3.13.1
Using CPython 3.13.1
Creating virtual environment at: .venv
Activate with: source .venv/bin/activate
tom@tom-VirtualBox:~/test_env$ source .venv/bin/activate
(test_env) tom@tom-VirtualBox:~/test_env$ uv pip install pyperclip
Resolved 1 package in 8.32s
      Built pyperclip==1.9.0
Prepared 1 package in 1.04s
Installed 1 package in 1ms
 + pyperclip==1.9.0

(test_env) tom@tom-VirtualBox:~/test_env$ python
Python 3.13.1 (main, Jan 14 2025, 22:47:38) [Clang 19.1.6 ] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import pyperclip
>>> exit
Thank you for your reply, but I didn't understand very much of it.
The Python version I am using is 3.12.3 (which is what came with Ubuntu 24.04)
When I use pip I get an error message

"This environment is externally managed
╰─> To install Python packages system-wide, try apt install python3-xyz, where xyz is the package you are trying to
install."
which is what I did when I installed pyperclip.

I do not understand what your code snippet is doing - downloading pyperclip (& compiling it?). Nor do I properly understand what a virtual enviromnent is, and why it is useful/necessary to use one. Nor do I see evidence that whatever you have done has fixed my problem.

Thank you hor your help, and sorry to be so negative about it.
OAP Wrote:When I use pip I get an error message

"This environment is externally managed
╰─> To install Python packages system-wide, try apt install python3-xyz, where xyz is the package you are trying to
Do sudo apt install python3-pip,this should install pip for Python 3.12.3.
Then try pip install pyperclip

Also look at uv is the new approach to a make universal tool for Python.
uv Wrote:A single tool to replace pip, pip-tools, pipx, poetry, pyenv, twine, virtualenv, and more.
10-100x faster than pip