Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ENH] - Enable clipboard #1796

Closed
adrienpacifico opened this issue Oct 3, 2022 · 11 comments
Closed

[ENH] - Enable clipboard #1796

adrienpacifico opened this issue Oct 3, 2022 · 11 comments
Labels
tag:Documentation Related to user, developer, and maintainer documentation type:Enhancement A proposed enhancement to the docker images

Comments

@adrienpacifico
Copy link

adrienpacifico commented Oct 3, 2022

What docker image(s) is this feature applicable to?

datascience-notebook

What changes are you proposing?

This code does not work with docker images:

import pandas as pd
df = pd.read_clipboard()

It throws a PyperclipException.

I do not know if it is possible, but it would be really nice to have this working with docker images.

How does this affect the user?

  • The use will be able to use any library that needs to access to the paperclip.

Anything else?

No response

@adrienpacifico adrienpacifico added the type:Enhancement A proposed enhancement to the docker images label Oct 3, 2022
@Bidek56
Copy link
Contributor

Bidek56 commented Oct 3, 2022

Does anyone know how to fix this issue?
After installing xclip and xsel I can not get pd.read_clipboard() to work in a Lab on a MacOS.

@mathbunnyru
Copy link
Member

Hi @adrienpacifico!
I guess I found the solution here: asweigart/pyperclip#161 (comment)
I haven't checked it out, but please try it.

I also think this issue is not related to our docker images in particular and you should use the thread with the message I mentioned (that's why I'm closing this issue).

@mathbunnyru mathbunnyru closed this as not planned Won't fix, can't repro, duplicate, stale Oct 3, 2022
@adrienpacifico
Copy link
Author

adrienpacifico commented Oct 3, 2022

Hi @mathbunnyru!

I am a bit sad that you closed the issue, as I think that being able to copy/paste at least for local jupyterlab docker image could be a nice option to have!

It could be:

  1. Documented on how to proceed on https://jupyter-docker-stacks.readthedocs.io/
  2. Maybe have xclip installed in minimal-notebook (not in base).

If anyone interested, I made it work on a debian based linux with the following method:

  1. Start jupyterlab container with docker run --network host -v $(pwd):/home/jovyan/work -e GRANT_SUDO=yes --user root -e DISPLAY -it -v /tmp/.X11-unix:/tmp/.X11-unix jupyter/base-notebook

  2. copy paste the link from your terminal in your browser to access to Jupyter.
    example:

Or copy and paste one of these URLs:
        http://pop-os:8889/?token=c370a0043b9bf8e2e10c39a501fe96f4fbe52da9f58bbfd0
  1. From jupyter/jupyterlab install xclip with !sudo apt-get update if you are in a notebook cell (or remove the ! if you use jupyterlab's terminal).

  2. From jupyter/jupyterlab install xclip with !sudo apt-get install xclip --yes if you are in a notebook cell (or remove the ! if you use jupyterlab's terminal).

  3. Install pandas if needed based on the docker image you are using an image that do not contain it

import pandas as pd
pd.read_clipboard()

And it works 🎉

It would be interesting to me to know if there exist a solution like that for macos (or windows).

@mathbunnyru
Copy link
Member

Great solution @adrienpacifico!
I guess you're right and I was a bit too fast to close this issue.

Could you maybe share your instruction as a recipe?
https://jupyter-docker-stacks.readthedocs.io/en/latest/contributing/recipes.html

It will be easier for people to find it in the docs (and not in the github issue).

@mathbunnyru
Copy link
Member

I would also suggest formulating it as a Dockerfile inherited from our Dockerfiles (to be persistent), and not to be run from jupyter terminal.

@Bidek56
Copy link
Contributor

Bidek56 commented Oct 3, 2022

I believe copy/paste should work without any libs on Windows, but I have not tested it.
The above solution does not work on MacOS 12.6

@mathbunnyru mathbunnyru reopened this Oct 3, 2022
@adrienpacifico
Copy link
Author

Thank you @Bidek56!
Sadly, clipboard on Macos seems to be stored only in ram (and not on the filesystem). Thus you cannot just link tmp/.X11-unix:/tmp/.X11-unix volumes. That would probably need a non-trivial solution.

@mathbunnyru gotcha! I did not know about recipes! It is quite nice! I will do it when I can (except if someone wants to write the recipe).

@mathbunnyru mathbunnyru added the tag:Documentation Related to user, developer, and maintainer documentation label Oct 5, 2022
@mathbunnyru
Copy link
Member

Let's see how much megabytes the package adds to the image size.

@mathbunnyru
Copy link
Member

@adrienpacifico as you suggested, I added xclip to the minimal image.
The image will be updated in around 1h30min.
Could you please check after that, that the new image works fine?

And this is the essential part to enable clipboard on Linux host system, right?
-e DISPLAY -v /tmp/.X11-unix:/tmp/.X11-unix

@adrienpacifico
Copy link
Author

adrienpacifico commented Oct 6, 2022

@mathbunnyru,

I am sorry, I was using an old version of jupyterlab image, I just repulled the last version, and I have an error when I launch a jupyter kernel/open a notebook (Server Connection Error).
I cannot confirm if it works. It seems that the issue I am facing has not an opened (or closed) issue on this repo. I may need to fill one --> #1800

And this is the essential part to enable clipboard on Linux host system, right?

The answer is yes. However, I have not tried without the -e DISPLAY option, it might be unnecessary.

@mathbunnyru
Copy link
Member

@adrienpacifico I updated the docs.
Please, check again, that the latest image works well for you (and reply here).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
tag:Documentation Related to user, developer, and maintainer documentation type:Enhancement A proposed enhancement to the docker images
Projects
None yet
Development

No branches or pull requests

3 participants