Products | Versions |
---|---|
Spotfire Data Science | 6.x |
How to Add External Images to a Notebook
How to Add External Images to a Notebook
If you want to include local images in your Jupyter notebooks, follow this process:
1. Create a new notebook and run the command !pwd
. Take note of the part in bold. (see the attached screenshot)
This tells you the name of the Docker image. Take note of the directory chorus_notebook.tmp.258
. You will need that in the following steps.
docker ps
to show a list of currently running Docker containers. (see the attached screenshot)chorus_notebook.tmp.258
from above? Find the row in the output that has that name. That is the Docker container that is running your notebooks. Each user has their own Docker container to run notebooks, and it is associated with their user ID in Chorus.docker ps
to determine the container ID. In the example above, the container ID is 166c70c811f3
.
5. Now copy the image(s) you want into the proper directory on the Docker container:
docker cp Demo_image.png 166c70c811f3:/home/chorus/ChorusCommander/chorus_notebook.tmp.258/
Be sure that you replace the 166c70c811f3
with the container ID from step 3.
6. Next, you'll need to set the permissions on the image file so the notebook can read it. Execute the below command, which will open a shell into the Docker container.
docker exec -it --user root 166c70c811f3 /bin/bash
7. Once you are at the shell for the Docker container, navigate to the directory where you placed the image file(s). In this example, that would be /home/chorus/ChorusCommander/chorus_notebook.tmp.258/
.
8. Add permissions for all users to be able to read the file:
chmod a+r Demo_image.png
9. Now exit and you should be able to include the images in your notebook using the image() function.