Jupyter Notebook "hidecode" tag not working? - jupyter

I am trying to use the hidecode tag as shown here, but for some reason, it's not working on my local Jupyter Notebook server. The code remains visible, and no button on the right of the cell is displayed. I even downloaded the same notebook used in the page above, no dice.
I am running Ubuntu 18.04.2 LTS, Jupyter Notebook Server 5.2.2, Python 3.6.7, and IPython 5.5.0. The command I ran to start the server is sudo jupyter notebook --allow-root.
If you need any more info, please let me know. I appreciate any help I can get in figuring this out.

If you want to hide the code, the output or the prompt of your cells you can install the hide_code extension:
https://pypi.org/project/hide_code/0.2.0/
Stop jupyter
Run these commands
pip install hide_code
jupyter nbextension install --py hide_code
jupyter nbextension enable --py hide_code
jupyter serverextension enable --py hide_code
NOTE: I run the first two commands as root and the last two with the same user used to launch jupyter.
Restart jupyter
I found this extension very useful because I needed to print the notebook to a pdf file and all the tools like nbpublish, nbconvert was failing. In this way I can print the notebook directly from the "print" feature of the browser.

Related

Open JupyterNotebook from VScode into the Browser

I have opened my .ipynb file with vscode (Python 3.9 Interpreter - installed jupyterlab), it's connected locally, how can I open it through the browser? what is the default port?
Type:
jupyter notebook in vscode terminal (Ctrl + Shift + ~) and it will start Jupyter in browser of your preference.
If jupyter not installed type:
pip install jupyter in elevated powershell or however you prefer to do installs.
If pip not installed:
python -m pip install -U pip
if python not installed I prefer to install with chocolatey and walkthrough is on their site. https://docs.python-guide.org/starting/install3/win/#install3-windows
I do not have a solution, but only hints. You can let Code start a local server via Ctrl + Shift + P, then Jupyter connect , then select default.
Unfortunately, it's not documented how you can access the server. I gave that feedback on the documentation page.
Source of the image: https://code.visualstudio.com/docs/python/jupyter-support#_connect-to-a-remote-jupyter-server
You can list all running notebooks and their tokens by typing jupyter notebook list in the terminal.
It will output something like this:
Currently running servers:
http://localhost:8889/?token=your_token :: /directory
You can click on the link to open it in the browser.
A solution for CORS-related issues:
In my case, the problem was in my CORS configuration. What fixed it for me was launching the notebook from the terminal with the allowed origin specified:
jupyter notebook --no-browser --NotebookApp.allow_origin_pat=https://.*vscode-cdn\.net
If, for some reason, that doesn't work, you could try the following as a last resort (bearing in mind this will allow ANY origin):
jupyter notebook --no-browser --NotebookApp.allow_origin='*'
Source:
https://github.com/microsoft/vscode-jupyter/wiki/Connecting-to-a-remote-Jupyter-server-from-vscode.dev

Jupyter: magic %qtconsole doesn't work

I am trying to use the magic %qtconsole from jupyter notebook.
I am working on my local connected to a remote server.
WHen typing %qtconsole and shift-enter in a cell of the notebook, nothing happens. No error message, but not qt console either.
Does that have to do with the remote server? Anyone has an idea how to resolve that problem?
You don't say much about your environment, but you may need to install qtconsole. If you are in a conda environment try...
conda install qtconsole
... or in general...
pip install qtconsole

PyCharm freezes after executing IPython Notebook cell

My PyCharm freezes after running any code in .ipynb (Jupyter Notebook) file.
i.e. the cell starts running and after that PyCharm doesnt respond and I have to kill it. No message is shown.
.py scripts are running correctly. Can anyone help?
My versions:
PyCharm Community Edition 2016.2.3 (Ubuntu 16.04)
ipython 5.1.0 py35_0
jupyter 1.0.0 py35_3
notebook 4.2.3 py35_0
It appears that your jupyter kernel is not running.
I have had success by first starting a jupyter notebook from the command line:
$jupyter notebook.
Then go back to the PyCharm jupyter notebook and run a cell. If you get the dialog box to enter the Jupyter Notebook URL, enter the url printed to your command line terminal session after you started the notebook there.

How to enable ipyparallel for Jupyter?

There're docs scattered under Jupyter or ipyparallel, but there's no a single piece document illustrating the entire process from beginning to end. I am really confused. Can anyone has experience to share?
Here are checks about my environment.
$ipcluster --version
5.2.0
$which -a ipcluster
/home/etlolap/anaconda3/bin/ipcluster
/user/bin/cluster
$head -n 1 $(which ipcluster)
#!/home/etlolap/anaconda3/bin/python
I can see the Clusters tab in Jupyter but it still prompts to ask for installation of ipyparallel.
To enable the IPython Clusters tab in Jupyter Notebook:
ipcluster nbextension enable
But I got the following issue hence it didn't work. It looks that nbextension is even not a valid argument.
No subcommand specified. Must specify one of: ['start', 'stop', 'engines'].
If you are using pip, this will get you the Jupyter notebook and IPython parallel:
pip install notebook ipyparallel
The package is fully functional at this point. You can start clusters with ipcluster and connect to them from notebooks. After installing ipyparallel, you can enable the IPython Clusters tab in the notebook dashboard:
ipcluster nbextension enable
If you are using conda-forge, installing ipyparallel will automatically enable the extension:
conda install -c conda-forge notebook ipyparallel
If you are using conda but not the conda-forge packages (e.g. Anaconda), or you otherwise don't see the IPython Clusters tab, you can still run the command above to enable the extension:
ipcluster nbextension enable
Or disable it with:
ipcluster nbextension disable

Highlight typos in the jupyter notebook markdown

When I write something in the jupyter notebook markdown field, the typos are not highlighted and often I ended up with something like this:
In almost all IDEs I have used so far, the typos are highlighted with a curly underline which was very convenient for me. Something like this:
Up till now I have not found anything that allows me to see this type of highlights. Does it exist?
The popular Jupyter Notebook bundle extension from Jupyter-contrib contains a spell checker. You can install and enable this (with admin privileges) like so:
pip install jupyter_contrib_nbextensions
jupyter contrib nbextension install --user
jupyter nbextension enable spellchecker/main
This may be the most popular spell checker for Jupyter Notebooks, but note that it simply highlights words not in its dictionary, and does not offer corrections.
If the extension installed properly, you will see this message in the command line:
Now, in the browser, after opening Jupyter, you will see the button labelled "abc" beside the keyboard button, which you can toggle to enable/disable spell check:
The jupyter-contrib library has many other useful modules such as code folding and table of contents.
Run the following in a terminal:
ipython install-nbextension https://bitbucket.org/ipre/calico/downloads/calico-spell-check-1.0.zip
ipython install-nbextension https://bitbucket.org/ipre/calico/downloads/calico-document-tools-1.0.zip
ipython install-nbextension https://bitbucket.org/ipre/calico/downloads/calico-cell-tools-1.0.zip
jupyter nbextension enable calico-spell-check
You can see typos like
Find out more
Afterwards, you need to activate the spell check in the Jupyter Notebook:
%%javascript
IPython.notebook.config.update({
"load_extensions": {"calico-spell-check":true,
"calico-document-tools":true,
"calico-cell-tools":true
}
})
The spellchecker and some other extensions from jupyter_contrib_nbextensions is incompatible with the ipython version 5.8.0. and later. (Found that it works in some cases for the version 5.0.0 [refer issue page of the same]. I'm not aware of its compatibility for the ipython versions between 5.0.0. to 5.8.0., please do comment if anyone knows).
The calico's nbextension 'spellchecker' available at https://bitbucket.org/ipre/calico/downloads/calico-spell-check-1.0.zip is an outdated version [dated 2015]. But calico had updated their nbextensions and made avaliable at the github repository [latest dated 2018]. It works fine for the ipython version 5.8.0.
Installation
git clone https://github.com/Calysto/notebook-extensions.git
cd notebook-extensions
jupyter nbextension install calysto --user
jupyter nbextension enable calysto/spell-check/main
Check its status:
jupyter nbextension list
When you now open or reload a notebook, there would be a new button visible with a check mark icon next to the button to open the command palette. You may click on it to check the spelling mistakes in the markdown cell.