Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Jupyter Notebook exported HTML dark color

I am using JupyterLab with light theme and when I exported my notebook as HTML I saw this: background color is dark and codes are in weird colors

What I am expecting to see is something like this: background color is white

any ideas of the setting ?

like image 491
kyle chan Avatar asked Mar 27 '20 22:03

kyle chan


People also ask

How do I get rid of dark mode in jupyter notebook?

Run "pip install jupyterthemes" This should show you the themes installed/ cached by jupyter notebook. Now run "jt -r" to reset the theme to default as shown below. Open and test jupyter notebook. Theme should be gone now.

How do I export HTML from jupyter notebook?

This method is as simple as clicking File, Download as, HTML (. html). Jupyter will then download the notebook as an HTML file to wherever the browser defaults for downloaded files. Screenshot of export by author.

Does jupyter notebook have dark theme?

By default, Jupyter Notebook uses the light theme. Some of the programmers or data scientists like to use some dark themes or other themes on different platform such as PyCharm, Spyder, etc. Jupyter Notebook does not come up with an inbuilt option to change the theme of the notebook.

How to export a Jupyter Notebook in black and white?

Alternatively, the complete Jupyter notebook is at this link: Sample_ipynb.ipynb First, we export the notebook as html file: Fig. 2. Exporting notebook as .html file. Printing the notebook directly (File -> Print Preview -> print (Ctrl+P)) to a printer device renders the notebook in black and white 2. Fig. 3.

How to download Jupyter Notebook as HTML?

Download Jupyter Notebook as HTML The most strightforward way to get HTML file from Jupyter Notebook is to use Download as function inside the Jupyter application. Please click on File in the top navigation bar, and then Download as to see many options of download formats (PDF, HTML, Python, LaTeX). Please select HTML (.html).

What are the best themes for Jupyter Notebook without dark mode?

If you are not interested in dark mode, you can try this following themes Alternative themes in Jupyter Notebook (Image by Author). Left: gruvboxd themes, middle: monokai, Right: solarizedd. Light themes in Jupyter Notebook (Image by Author).

How to suppress the visibility of the code in Jupyter report?

One way to suppress visibility of code cell is to use JQuery (javascript) in the separate Jupyter cell as per 4, 5: We can toggle visibility of the code in the html report (rendered output) displayed in the browser.


2 Answers

I had the exact same issue. After a couple hours debugging I realized it had to do (for me at least) with the jupyter-theme library. I had a dark theme installed, and I think nbconverter uses whichever settings your jupyter is also using, so the dark settings were affecting the html conversion.

Solution was simply to restore defaults with: $ jt -r

If that doesn't work, then refer to this thread: https://github.com/dunovank/jupyter-themes/issues/86

like image 169
Rafael Marino Avatar answered Nov 02 '22 14:11

Rafael Marino


from the command line run:

jupyter nbconvert --execute --to html /path/to/example.ipynb --HTMLExporter.theme=dark

adding --execute guarantees that plots are rendered before saving.

you can use Plotly dark theme to have plots black as well

import plotly.io as pio
pio.templates.default = "plotly_dark"

enter image description here

like image 29
MAFiA303 Avatar answered Nov 02 '22 13:11

MAFiA303