简体   繁体   中英

How to configure JupyterLab to look the same when opened?

I'm developing a small application using JupyterLab that I will distribute around the world. I would like to configure JupyterLab so that when my users download my code, move into the directory, and execute jupyter-lab , they will always start with the same view.

For example, I want JupyterLab to open up with the README.md file shown rendered as markdown. I don't want Python or Jupyter Notebook files opened (initially).

Is there a way to configure JupyterLab in this way? *

You can use jupyterlab-workspace.json file to specify layout. Here are some examples:

They work by executing the following command before starting up JupyterLab:

jupyter lab workspaces import jupyterlab-workspace.json

Do NOT try to create the JSON file manually (do not use them as a reference). Instead create a new workspace, arrange tabs/files as you wish and then use:

jupyter lab workspaces export workspace_name > jupyterlab-workspace.json

See the workspaces documentation for more details. There is also a relevanttopic on discourse .

For your particular use case I would just create a file with a script that your users would use instead of executing jupyter-lab , eg a simple two-liner like:

jupyter-lab workspaces import jupyterlab-workspace.json
jupyter-lab

But if you just want one single file to be shown you may as well just create a wrapper that asks for that file to be opened like:

jupyter-lab README.md

Please note that there was a bug that meant that above did not work some time ago (it is working well if you have the latest versions of jupyterlab-server , jupyter-server , jupyterlab ; while updating remember to update nbclassic - if installed - as well).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM