As described in a previous question, it is now possible to edit the Jupyter Lab theme. However, this theme has a few issues for me personally. For example, it makes plot axes hard to read, since their default color is black. Other users have had similar problems. Consequently, I would like to fork the existing theme and make plot display cells a light grey colour. How does one do this?
I tried to find the corresponding .css file, but all I could find was /usr/local/share/jupyter/lab/themes/#jupyterlab/theme-dark-extension/. I understand that I could edit the index.css to achieve what I want, but how do I instead fork that theme and edit it? How do I let Jupyter Lab know about my custom theme?
First fork the Jupyter Lab project, then edit and commit your
changes.
Second, go to Jupyter Lab project and ask pull request.
if they like your project they will accept and put your changes on
their master branch
To expand on the answer from #Payam Khaninejad once you've forked the Jupyter Lab project you need to find the variables.css file and make your desired edits.
Then you can join the current (as of posting) issue on Github https://github.com/jupyterlab/jupyterlab/issues/3855 and get help to format your pull request to conform to the style used by the Jupyter Lab project. Info on contributing to the project here.
Here's a reply I wrote another question detailing the steps to make changes to the Jupyter Lab interface:
To edit Jupypter Lab themes you need to make changes to the file variables.css which is located in jupyterlab/packages/[THEME NAME]/style/
You can inspect the element of the Jupyter Lab that you'd like to change to find out its class. I used Chrome DevTools ctrl+shift+i and click on various div classes until I found the one I wanted to alter.
Once you have the name of the div class you'd like to customize, add the changes to the variables.css file. Here's what I changed and the result.
.jp-RenderedImage {
background-color: #A4A4A4
}
You can use this gist (where the code in the first cell comes from) created by one of the JupyterLab contributors to experiment with changes you made to the variables.css file.
we are using version 0.35.x ...
the following steps worked for me ... it will create a clone of the light theme, would install it in jupyter lab and you would be able to select that from settings menu. you can customize this theme, build it and have the effect in jupyter lab
install miniconda from here https://docs.conda.io/en/latest/miniconda.html (chose python3.7 one)
open Anaconda Terminal, [in windows goto search type Anaconda, select the terminal]
then run this conda create -n jupyterlab-ext -c conda-forge --override-channels nodejs jupyterlab cookiecutter git
clone jupyterlab from here https://github.com/jupyterlab/jupyterlab.git
switch branch with git checkout 0.35.x
then jlpm install
jlpm build
npm run create:theme
copy the theme folder to your chosen local theme folder for extension development. Replace tsconfig.json content with the following
{ "compilerOptions":
{ "declaration": true,
"lib": ["es2015", "dom"],
"module": "commonjs",
"moduleResolution": "node",
"noEmitOnError": true,
"noUnusedLocals": true,
"outDir": "lib",
"rootDir": "src",
"strict": true,
"strictNullChecks": false,
"target": "es2015",
"types": []
},
"include": ["src/*"]
}
[created by the steps here https://jupyterlab.readthedocs.io/en/stable/developer/xkcd_extension_tutorial.html#xkcd-extension-tutorial]
inside the theme folder ..
run the following commands jlpm install, jlpm run build , jlpm run build:webpack
open another conda terminal, there go to repo folder and run conda activate jupyterlab-ext then jupyter labextension install .
in a conda terminal conda activate jupyterlab-ext then, jupyter lab --watch
For version 1.0 , this cookie cutter could be used ... https://github.com/jupyterlab/theme-cookiecutter
Related
I'm using zsh on Linux with OhMyZsh and the powerlevel10k theme. I'm also using nvm since I have to switch node versions for different projects.
I'd like to achieve that zsh automatically uses the node version set in the .nvmrc file (if one exists). That should be triggered when changing into a directory that has a .nvmrc file, but also when opening a terminal (e.g. opening a vscode project, the internal terminal should be set to the respective node version).
I tried the ohmyzsh nvm plugin (with export NVM_LAZY=true and export NVM_AUTOLOAD=true), but that causes this behavior with powerlevel10k when opening a terminal:
[WARNING]: Console output during zsh initialization detected.
When using Powerlevel10k with instant prompt, console output during zsh
initialization may indicate issues.
...
The zsh-nvm plugin works better (with export NVM_LAZY_LOAD=true and export NVM_AUTO_USE=true). It automatically changes the version when changing directories, however not when opening the terminal.
I achieved that by adding this line to my .zshrc file:
[ -s "./.nvmrc" ] && nvm use > /dev/null 2>&1
That does not cause the above mentioned powerlevel10k issue, however the terminal changes the look (applying the powerlevel10k theme) after a couple seconds. I guess that is because of loading nvm right away (and not lazy loading it anymore). If I open the terminal in a directory without .npmrc, it opens fast and with the p10k theme right away.
I can live with this setup, but it is still not ideal and feels hacky. Is there a better way to do it?
Just for reference, there is also this issue on the zsh-nvm github
I'm trying to modify the main menu of jupyter lab through jupyterlab extension. What I want to do is to remove or collapse all tabs into one. As I didn't find any explanation on that I tried to follow a tutorial to work with menu tabs: https://github.com/jupyterlab/extension-examples/tree/master/main-menu
However, I'm not being able to reproduce it. I run these commands on the terminal (inside the main-menu folder):
python -m pip install -e .
# install your development version of the extension with JupyterLab
jupyter labextension develop . --overwrite
# build the TypeScript source after making changes
jlpm run build
# start JupyterLab
jupyter lab
But the "Main Menu Example" tab never appears.
What could it be? some cache information that I need to clean?
I recently installed nbextensions in my conda environment to add the ability to add a Table of Contents (toc2) to my notebooks. But I did this while having a jupyter notebook open and after installing the extension, changes in the extension settings didn't reflect on the notebook I had open during installation while it did on the others that weren't.
I tried shutting down and restarting the kernel, restarting the computer, and uninstalling and re-installing nbextensions again (following these instructions on a github ticket). None of these things rectified the issue with the notebook that was open. A duplicate of the notebook inherits its problems.
An interesting thing to note is that after reinstalling nbextensions, which was my last attempt, changes of the settings from the first install were held over instead of going back to default (ie color settings in nbextensions being the distinct colors I had switched them to before the uninstall). I'm not sure if I fully uninstalled nbextensions or if it's really possible. And after the re-install, further changes in the settings in the second go-around didn't reflect on any notebooks afterwards, like removing the sidebar toc setting after selecting it the first time, the sidebar remains in certain notebooks.
I'm not sure what's going on but:
1.) Is there a way to get the settings changes to reflect on the notebook universally, particularly having a toc? Especially on the notebook that was open at the time of install?
2.) Is there a way to totally un-install nbextensions like it never existed on my machine so I can try this again?
Step 0 - Is this a problem with the Notebook metadata?
The toc2 module adds some metadata to the notebook.
Just in case this metadata is missing, has wrong values, or the defaults written make the ToC does not show up try this:
Open the notebook and select "Edit"->"Edit Notebook Metadata".
Remove the "toc":section if it exists an add this to the end of the metadata:
"toc": {
"nav_menu": {},
"number_sections": true,
"sideBar": true,
"skip_h1_title": false,
"base_numbering": 1,
"title_cell": "Table of Contents",
"title_sidebar": "Contents",
"toc_cell": true,
"toc_position": {
"height": "382px",
"width": "256px",
"left": "10px",
"top": "10px"
},
"toc_section_display": true,
"toc_window_display": true
}
Be careful not to remove any comma(,) after the closing } if exists ! This must be a valid JSON file.
After changing the metadata:
Clic on the "Edit" button
Save the notebook
Close the browser window
Annd open the notebook again.
You should see a floating TOC window.
If not, go to the next step.
Step 1 - Is this a Jupyter problem?
Check the jupyter_contrib_nbextensions is installed (pip freeze | grep jupyter_contrib_nbextensions).
Open jupyter and check there is a 'Nbextensions' tab next to the 'Clusters' tab on the home page.
Open the 'Nbclusters' tab and leave unchecked the ' disable configuration for nbextensions without explicit compatibility (they may break your notebook environment, but can be useful to show for nbextension development)' box.
Now look for the 'Table of contents (2)' extension and enable it.
Now your should see the TOC when you open the notebook.
If not, go to the next step.
Step 2 - Is this a browser-related problem?
Looking at the toc2 extension soure we can see this is client-based based on Javascript code.
When you load the Jupyter notebook, the module main.js is added to the .js your browser runs and modifies some menu commands.
To discard we have caching issues, open Jupyter using with a 'fresh' browser.
This could be either:
Another browser (chrome, firefox, Edge..)
Or your 'normal' browser in incognito/InPrivate mode
With a 'clean' browser you should be able to open the notebook and see the navigation bar from the TOC extension.
What to do now:
If the Clean browser works, but the "normal" browser doesn't
clear cache in the normal browser and try again.
If the Clean browser does not work and Jupyter is running on your local machine.
We've hit a bug here.
Open your browser developer tools, open a ticket in github, and add the console output from developer tools.
If the Clear browser does not work and Jupyter is running on a remote machine
Do you use a proxy? or is your ISP using transparent caching for this page/parts of the page (last one is hard to assess).
Try running Jupyter in another port (with the --port option). That should fix he problem. Consider using https instead of http to avoid caching by intermediate network.
When I click "New" to create text file,folder, and python3 file on jupyter notebook, it shows that "Creating File Failed" and "An error occurred while creating a new file". Could you please give me some advice about how to solve this problem ? The screenshot is attached. Thank you very much !
Some details: I use pip install jupyter to install jupyter notebook in Linux environment. You can see from the attached screenshot that there is a new icon near to the upload icon on the upper right, then I click the black upside-down triangle on the new icon, then I choose folder. This is the process in which I try to create a new folder on jupyter notebook.
Use the --user tag with pip
The reason you cannot create a folder is because you do not have permission. This could be that you are not a on the sudo list or that you are not the owner of the folder where you are trying to create a new folder.
You can potentially avoid these problems by removing your jupyter install and re-installing with the '--user' option. Be sure that you have configured a non root user with sudo privileges and that you are logged in as that user. Try the following:
pip uninstall jupyter
pip install jupyter --user
Run notebook as usual:
jupyter notebook
One more thing, be sure that you are trying to create a folder in your home directory. If you are user "Bob", make sure you are creating the folder in /home/bob/ You are the owner of this directory and should be able to modify it as you wish.
Further reading:
link1
link2
I have found reasons that I cannot create new folder/file on jupyter notebook. Reason is that I directly open jupyter notebook in the anaconda3 environment, that's incorrect! Intuitive description is that I should switch from /home/${USER}/anaconda3 to /home/${USER}/anaconda3/bin, because when I use whereis jupyter, I find that jupyter is under /~/bin directory. So, I have a try and succeed !
I'm trying to install the great table of contents extension in a new computer. but I cant find it anymore. the only page I do find does not explain how to install the extension on windows.
So.. How can I install it, and why is it not a part of the official Ipython notebook? I simply can't understand how people are getting along without it.
I've installed toc nbextension successfully with Jupyter 4 (ie. ipython notebook 4) recently.
In fact installing extension is easier than before :)
I post my solution here, may it help.
## download
mkdir toc
cd toc
wget https://raw.githubusercontent.com/minrk/ipython_extensions/master/nbextensions/toc.js
wget https://raw.githubusercontent.com/minrk/ipython_extensions/master/nbextensions/toc.css
## install and enable
cd ..
jupyter-nbextension install --user toc
jupyter-nbextension enable toc/toc
A bit more explain:
install will copy toc to ~/.local/share/jupyter/nbextensions/
enable will modify ~/.jupyter/nbconfig/notebook.json.
You can check these two place to see what happened.
Note: we use enable toc/toc here is because toc.js is in ~/.local/share/jupyter/nbextensions/toc/.
If you put toc.js and toc.css directly in ~/.local/share/jupyter/nbextensions/ then you should use enable toc here.
Edit
Sorry, I didn't notice the orginal problem is on windows. I'm not sure if it's same for windows jupyter, any report is welcome.
Update
Now the toc nbextension has been added into this project which provide a collection of kinds of nbextensions. It's very easy to install and manage, worth to try!
I cannot tell you specific Windows advice, but think the key points should be platform independent:
Create a profile (either a default profile or a named one - you'll probably want default to start).
Locate where the profile is.
Add the custom.js file into the profile.
Edit the custom.js file to point to the notebook extension code.
In a bit more detail, setting up a profile is covered in detail here but for a default profile just go to the command line and enter
ipython profile
Next, locate where your profile is stored by typing at the command line
ipython locate
Call that <profile_dir>.
The rest follows the (Windows equivalent of!) the instructions on the link you have: underneath <profile_dir> navigate to (creating any directories that do not already exist)
<profile_dir>/static/custom/
and add the custom.js file as shown. Then edit the first line, where it has "nbextensions/toc" to point to the location where you have placed the toc.js file you have downloaded. This location is relative to the <profile_dir>; for me I have
<profile_dir>/static/custom/custom.js
<profile_dir>/static/custom/nbextensions/toc.js
<profile_dir>/static/custom/nbextensions/toc.css
and the first line of custom.js reads
require(["/static/custom/nbextensions/toc.js"], function (toc) {
Finally, note that this is with version 1.1.0 of the notebook - if you're using an earlier version I strongly suggest you upgrade before trying this.
You'll also find the official installation instructions at:
https://github.com/minrk/ipython_extensions
These instructions include curl commands for retrieving the toc.js and toc.css files from GitHub, which worked fine for me in a bash shell on linux Mint.
For Windows 7, I used a Git Shell (see http://msysgit.github.io/) to execute the curl commands
This IPython Notebook semi-automatically generates the files for minrk's table of contents in Windows. It does not use the 'curl'-commands or links, but writes the *.js and *.css files directly into your IPython Notebook-profile-directory.
There is a section in the notebook called 'What you need to do' - follow it and have a nice floating table of contents : )
Here is an html version which already shows it:
http://htmlpreview.github.io/?https://github.com/ahambi/140824-TOC/blob/master/A%20floating%20table%20of%20contents.htm