asweigart / pyperclip

Python module for cross-platform clipboard functions.
https://pypi.python.org/pypi/pyperclip
BSD 3-Clause "New" or "Revised" License
1.65k stars 196 forks source link

Does anyone know about this issue? - Pyperclip could not find a copy/paste mechanism for your system #227

Closed MoaMoa90 closed 2 years ago

MoaMoa90 commented 2 years ago

Hi, everyone i'm using oracle arm/amd processor servers with ubuntu 22.04

i have searching for an solution for this over 1 week more than 100 hours

but i had no luck to figure out what is the problem

so if you know about this please help me!

what is problem :

here's a simply code with pyperclip


import pyperclip 

string = 'testing'

pyperclip.copy(string)

a = pyperclip.paste()

print()

whenever i execute this code directly in the cli , it is okay to run

However whenever i run this code with schedulers like Crontab or Systemd.timer (xclip && xsel is already installed) i got this error and cannot run the code like below


Traceback (most recent call last):
  File "/home/ubuntu/web_selenium/pytest.py", line 10, in <module>
    pyperclip.copy(string)
  File "/usr/lib/python3/dist-packages/pyperclip/__init__.py", line 689, in lazy_load_stub_copy
    return copy(text)
  File "/usr/lib/python3/dist-packages/pyperclip/__init__.py", line 358, in __call__
    raise PyperclipException(EXCEPT_MSG)
pyperclip.PyperclipException: 
    Pyperclip could not find a copy/paste mechanism for your system.
    For more information, please visit https://pyperclip.readthedocs.io/en/latest/index.html#not-implemented-error 

i tried most of solutions in stackoverflow, mostly it was about setting path for interpreter and packages of course i installed xclip and xsel as well / everything is good when i run code directly through cli but only when i run code or shell script through Crontab , Systemd.timer, this error is generated

  1. run pyperclip code through shell script with various python env PATH i tried to lay all the possible env path like /usr/bin:/usr/local/bin ....... and even my python pakages path as .profile and ~./bashrc - failed

  2. set new venv and install all the modules, run code - failed

  3. run as root - failed

  4. install new ubuntu and switch server ubuntu amd -> ubuntu aarch64 - failed

  5. reinstall module - failed

  6. set shebang inside of python script ( whereis python3 - inside of python file - #!/usr/bin/python3.10) - failed

  7. set shell into crontab (SHELL=/bin/bash) - failed


now i'm thinking this is the problem of pyperclip pleaese help me!