I accidentally pressed some buttons on while I was working on Jupyterbook. Now, each cell shows a 'Run this cell (play button)' icon, which is visually distracting. I cannot find a toggle switch/command to turn it off.
Is there anyway I can turn it off?
You most probably have upgraded the notebook package to the version 5.6.0 or higher.
pip show notebook
or
conda list notebook
will get you the exact version you have.
If the above is the case, unfortunately, your options are limited and are as follows.
Downgrade
pip install notebook==5.5.0
or
conda install notebook==5.5.0
Customize local CSS
Add the following code (сheck out this thread for more flexible and sophisticated solutions) to your custom.css file.
.code_cell .run_this_cell {
display: none;
}
If you're using Conda on Linux you can find the file at (depending on the version of Python you're on)
~/anaconda3/lib/python3.7/site-packages/notebook/static/custom/custom.css
For Conda on Windows try
C:\Users\UserName\Anaconda3\Lib\site-packages\notebook\static\custom\custom.css
Check answers to this question for more details on where the file could be found.
Alternatively, you can create a new file my-custom.css, put it anywhere you want and then reference it from every notebook individually by using IPython's HTML cell magic
%%html
<link rel="stylesheet" href="somewhere-on-your-machine/my-custom.css" />
or explicitly, without needing to create any files
%%html
<style>
.code_cell .run_this_cell {
display: none;
}
</style>
A simpler way of solving this is to select the cells, change them to markdown and then change back to code.
Related
I looked at Fira Code and I wanted to try it out with one of the listed supported editors. So I launched RStudio (Version 0.99.491 on a Win box) and set the font to Fira Code but ... nothing. So how to enable font ligatures in RStudio?
EDIT: The trick in the accepted answer below still works for RStudio Version 1.0.44. I still wish there's a simple button to enable it.
I still wish there's a simple button to enable it.
Wish granted! We've just added this to RStudio 1.1.
You can try the preview release here:
https://www.rstudio.com/products/rstudio/download/preview/
RStudio now have a build in option for ligatures, you do not need these dirty hack any more, cheers!
[OLD CONTENTS]
Close RStudio
Open [RStudio dir]/www/index.htm (If you are using a Linux distribution, the dir may be /usr/lib/rstudio, thanks for the comment of #CosminSaveanu)
Add following code between <head> and </head>:
<style>*{text-rendering: optimizeLegibility;}</style>
Restart your RStudio.
dirty but works.
If you are using Linux then type in your Terminal,
sudo apt install fonts-firacode
Restart Rstudio then in Tools / Appearance / Editor Font: choose Fira Code and Apply.
is there a way to control the layout of jupyter notebook when using it inside pycharm?
currently, I have a side by side display:
is there a way to change it into layout similar to the web's version in jupyter itself?
So that after every input cell, there would be the output of a cell...
thanks!
Not at the moment, unfortunately.
Update 1: PyCharm 2021.3+ has a new browser-like Jupyter layout by default (shared with DataSpell).
I know that I can click on File -> Print Preview and let my browser save the result as a PDF. But that PDF will contain quite a bit of code.
Can I hide parts from the print preview or make a PDF with another tool?
Ideally, there would be magic functions:
%hide: Hide the cell and its output
%hide-code: Hide only the code of the cell, but show the output of the code
Print to PDF in the browser
In JupyterLab, you can hide the cell's input and output by clicking the side bar as demonstrated in the doc. After hiding, you can use the browser's printing menu to generate a PDF. I've tested it on FireFox and expect similar result on Chrome or Edge.
Export to PDF with nbconvert
If you aim at a native conversion from ipynb format to pdf, the nice old nbconvert tool is your friend. It usually comes together with Jupyter and can be invoked conveniently in the menu of JupyterLab File->Export Notebook As...->PDF or, in the classic Jupyter Notebook interface, File->Download as->PDF (via LaTeX).
Hiding input/output in cells can be realized by setting the cell's metadata hide_input=true and installing a nbextension as discussed in issue #155.
Print Preview menu in the classical Jupyter
Finally to your question
Can I hide parts from the print preview or make a PDF with another tool?
The "print preview" button in the classical Jupyter interface is a shortcut for calling nbconvert to generate a HTML file and redirect your browser to it. Therefore, similar configuration for nbconvert to hide input as discussed above (in issue #155) can be used. This feature is implemented by jupyter_contrib_nbextensions bundle and explained in the doc.
As the above-mentioned answers do not work for me; I found another solution:
I use an additional package notebook-as-pdf.
Read the tutorial here. It uses Chromium and is the only approach that worked for me so far reliably. The "print preview" does still not work. But it produces a clean PDF with no code input.
I do:
pip install -U notebook-as-pdf
pyppeteer-install
jupyter nbconvert --to PDFviaHTML --TemplateExporter.exclude_input=True PATH_TO_YOUR_FILE.ipynb
What did NOT work for me:
The solution above.
All the scripts mentioned in those answers
I'm using the Base16 Ocean dark theme on IPython Notebook.
The background color of selected text doesn't contrast very well, making it difficult to tell if it's selected:
On the default settings, this does not occur:
Please let me know how to change the background color of selected code on IPython Notebook to a more clear one.
Run the following code in a notebook to find out the jupyter config folder on your system, if you don't know it yet:
from jupyter_core.paths import jupyter_config_dir
jupyter_dir = jupyter_config_dir()
print(jupyter_dir)
In the jupyter config folder, find /custom/custom.css, modify the following line:
.cm-s-ipython div.CodeMirror-selected {background: #384151 !important;}
I use '#3366ff' here, you may use whatever background color that suits your need.
All is well with jimmyazrael answer, but if you're using Jupyter 5.0 from within Anaconda3 you will find your css file at:
C:\Users\YourUsername\Anaconda3\Lib\site-packages\notebook\static\cutom\custom.css
Hope that helped
Mine was I bit more complicated. Couldn't find it in any mentioned folder, thus after searching my system for "custom.css", I have found many of this! It is likely because I had upgraded/downgraded my environment multiple times.
So, in the end, I open the file in:
C:\Users\username\AppData\Local\Continuum\anaconda3\pkgs\notebook-6.1.5-py37haa95532_0\Lib\site-packages\notebook\static\custom\custom.css
Pasted the line:
.cm-s-ipython div.CodeMirror-selected {background: #384151 !important;}
Saved and restarted Jupyter. It worked!
Jupyter notebooks (using IPython) print in black and white by default. By opening the developer's console, locating the relevant style file, and deleting various #media print styling options, I can print in colors. However, this is rather tedious to do.
Is there a way to set up a global configuration to override the default?
Jupyter version: 4.0.6
IPython version: 4.0
Looks like a patch just got accepted on this topic: https://github.com/jupyter/notebook/pull/3212.
It's apparently something of a hack because the offending code/template is pretty deep within a dependency. While it is being fixed by the dependency upstream, the newer version of the dependency is incompatible, so a more hack-ish patch is acceptable for now.
The fix just got accepted into the master branch of the source code, so it isn't yet available in a released version. If someone sees that it is, then this answer should be updated or a new answer submitted.
One workaround that I use:
File > Print Preview
In the preview tab, press Ctrl+A (Select All)
Print > Print selection only
Like flutefreak7 mentioned the issue is fixed.
If you are using an older version and you can't / don't want to upgrade, a workaround would be using the developer console / inspector of your browser to delete the color-set line in the media print section.
In Firefox you can solve this by:
Right click -> Inspect Element (Q)
Select the Style Editor tab
Press Strg+F and search for #media print
Delete or uncomment the line color: #000 !important; in the *:after section
Close the Inspector and enjoy printing in color mode!