Cant get pyperclip to use copy and paste modules on python3
The clipboard is part of your GUI. But you don't have a GUI. So there is no clipboard to copy and paste with. There is no clipboard for pyperclip to access, so it doesn't matter how you try to access it, you're going to fail.
You can test very easily by running this at the shell:
xclip
If it says something like Error: No display: (null)
, then that's your problem.
If you think you should have a GUI, because you've set things up to, e.g., tunnel X11 through ssh to an X server on your desktop machine, but you're still getting an error from xclip
, then the problem is that you've set things up wrong. The simplest thing to check is:
echo $DISPLAY
Is that empty? Then your session doesn't know anything about your X11 tunnel. Getting tunneling set up properly is really an issue for a site like Super User or Unix, not Stack Overflow—and, once you get that fixed, pyperclip
, and your script, should just start working.
As for what you can do about it… well, it depends on why you were trying to use pyperclip
in the first place. On a headless system, there's nowhere to copy data from, and nowhere to paste it to, so it wouldn't be particularly useful.
If you're trying to, e.g., share data between two different Python scripts on the same machine, then there are simpler ways to do that than passing it through a clipboard—just use a file, a pipe, a socket, etc.—that don't even require a third-party library with complicated setup.
pyperclip module raising an error message
This method fixed it for me.
pip install QtPy
also you could refer to this thread for more help
https://pyperclip.readthedocs.io/en/latest/introduction.html#not-implemented-error
Python 3 Pyperclip Installed but Module not Found
Pycharm uses a virtualenv for pycharm projects. Navigate through:
Pycharm >> File >> Settings(or press Ctrl+Alt+S on win) >> Project:Name >> Project Interpreter >> Click on the plus(+) symbol above the scroll bar and type in pyperclip and press install package.
And this will install pyperclip for your Pycharm IDE. Since pycharm uses a virtual env for its projects you can change it in the project interpreter section as well, and then the pyperclip you installed from the cmd using pip, will be available to be used on that global version of python(now used by your Pycharm too).
If you still have any errors or doubts, do let me know :D
Cheers
Pyperclip error on WSL2 running Ubuntu 18 LTS while trying to access data copied from windows
I noticed that the issue had to do with following block of code: pandas/io/clipboard/init.py#L523-L526
If I edit the line if "Microsoft" in f.read():
, and replace "Microsoft" with "microsoft" (lowercase "m"), then the clipboard functionality works for me.
Not a good long-term solution, but definitely a simple patch until pandas teams integrates this.
Using Pyperclip in Python 3 Does Not Paste Data in Desired Format
Try this way:
import pyperclip
text = pyperclip.paste()
lines = text.split()
pyperclip.copy(', '.join(lines))
Related Topics
Total Memory Used by Python Process
Difference Between 'Sorted(List)' VS 'List.Sort()'
How to Change a Global Variable from Within a Function
Get All Modules/Packages Used by a Python Project
Changing the Process Name of a Python Script
Python: Get Default Gateway for a Local Interface/Ip Address in Linux
Can You Fool Isatty and Log Stdout and Stderr Separately
/Usr/Bin/Env: Python2: No Such File or Directory
I Cant Init Google Cloud Sdk on Ubuntu
Subprocess.Popen: 'Oserror: [Errno 13] Permission Denied' Only on Linux
Linux Bash Script Running Multiple Python
What's the Advantage of Queues Over Pipes When Communicating Between Processes
Python: Xlib -- How to Raise(Bring to Top) Windows
Os.System() Execute Command Under Which Linux Shell
Conversion Text to Number in Python