I’m currently working with a JupyterHub instance running on Linux and encountering some challenges accessing my local clipboard. My goal is to copy a block of CSV data directly into a pandas DataFrame in my Jupyter Notebook.
I have tried to use the pandas.DataFrame.to_clipboard() method, but it seems not to work in this context. Specifically, it results in the following error: “PyperclipException: Pyperclip could not find a copy/paste mechanism for your system. For more information, please visit https://pyperclip.readthedocs.org”. This suggests that the Pyperclip module, which the function relies on, is unable to find a suitable copy/paste mechanism.
One workaround I’ve considered is copying the clipboard contents into a text file and then reading this file into the notebook. However, this method isn’t ideal as it introduces additional steps and isn’t as efficient as I’d like.
Another workaround I’ve tried is using the “ipywidgets” library to create an interactive text input field. This allows me to paste the clipboard contents into the field manually. While this works for smaller amounts of data, it doesn’t scale well for larger data sets.
Are there any better solutions or workarounds for this issue? I’m interested in any ideas or suggestions you might have that could allow direct access to the local clipboard, particularly in the context of a remote JupyterHub instance. I understand the security implications of this, but any guidance or resources would be much appreciated.
Thank you in advance for your time and assistance!
Hi! You’ve tagged this as JupyterHub, but it’s more likely to be related to your singleuser server, e.g. JupyterLab, or Notebook. Which are you using, and what version? I can update the tags for you if you want.
Thank you for your concern. I was just surprised about pandas.read_clipboard() - yes, it works for a local runtime with jupyter.
My application has grown a bit and moving to JupytherHub was an obvious choice. A central point for maintaining notebooks - no multiple installations of jupyther on office computers and laptops.
A small TLJH installation for 5 to 8 users, nothing special (about one-month-old - Ubuntu VM on Windows Server) . External software (WIN) provides a CSV data set - copy it briefly into the notebook, compare it with old data, save it, and make new settings. And yes, the way via a direct CSV file is possible, just a little more cumbersome - so it’s not the end of the world for me.