Jupyter Python logo - ipython

Does anyone know how to add Python logo to the top right corner of python notebooks in Jupyter ?
I see Ruby notebooks are added w/ Ruby logo automatically.
Can this be done in Python notebooks ?
Zarak, This is what I see
$ jupyter kernelspec list
Available kernels:
python2 d:\Continuum\Anaconda2\lib\site-packages\ipykernel\resources
ruby d:\eclipse\.ipython\kernels\ruby
$ pwd
/d/Continuum/Anaconda2/lib/site-packages/ipykernel/resources
$ ls
logo-32x32.png logo-64x64.png

This is NOT a solution, but an amelioration of the problem...
I had (still do) similar issue on my OS X 10.7. In my case, jupyter's python kernel, while not able to find logo-64x64.png file, would auto-redirect me to 404 page as soon as Notebook loads - so I was not able to use Notebooks at all.
If anyone else is having similar issue, I suggest to try any of the following steps (until you can use Notebook again). I still see 404 GET /kernelspecs/Python%20[Root]/logo-64x64.png message in Terminal - however, now I do not get redirected to 404 page automatically upon loading the Notebook.
initially I was using Firefox as default browser, however I switched to Chrome.
initially I only had kernel for python2.7 installed. Now I added kernel for python3.
I generally call jupyter with --notebook-dir argument. I copied into the folder I specify in that argument - the files from location, which I get by running jupyter kernelspec list (2 logo files and 1 json file)
In the end, I still have the same issue - and I am anxiously waiting for somebody else to respond with a solution. However, hope this helps some people in the meantime.

Related

Why has Jupyter notebook kernel stopped working after RStudio package installation

To date I have been using Jupyter Notebook to run R and sometimes Python code. I have also been using RStudio at times. Recently, while using RStudio, I was prompted to install some package (cannot exactly remember). At any rate, I installed this package. Dont know if only coincidence, but trying to run R in the notebook resulted in kernel not connecting. I found the same issue with Python, the Python kernel is also not connecting anymore.
Executing the below, I get;
(base) C:\WINDOWS\system32>jupyter kernelspec list
Available kernels:
ir C:\Users\Admin\AppData\Roaming\jupyter\kernels\ir
python3 C:\Users\Admin\anaconda3\share\jupyter\kernels\python3
How do I get Jupyter Notebook's kernels to work again.
Executing IRkernel::installspec() in R via Anaconda CMD prompt have resolved the issue. Note for others with this issue, you may be prompted to run install.packages(“rlang”) before.

add hide_code to jupyter notebook

I am trying to add the hide_code option to my ipython notebook (jupyter, version 4, python 2.7). It is supposed to add a button or an option to the cell pull-down menu that allows me to hide the code in my ipython notebooks. I have successfully run the 'pip install hide_code' command from the terminal (MacOS X El Capitan). I have restarted the notebook and expected to see a new I have tried to restart the notebook program but nothing happens. I am not computer savvy enough to know what to do from here. Did I miss something?
Here is the github repository for the code:
https://pypi.python.org/pypi/hide_code/0.3.0
OK I found a way to do it.
Install hide_code... It will not work, though.
Try to install it with (with dir="~/.ipython" or whatever)
import hide_code.hide_code as hc;
dir = "<full path to Jupyter config directory>";
hc.install(dir)
It will still not work, but it will copy a javascript file (hide_code.js) into that directory. We will use it in a bit.
Let's find where those nbextensions are. Find one of them. For example, keyboard_shortcut_editor:
cd ~
find -name keyboard_shortcut_editor
Mine finds it ./.local/share/jupyter/nbextensions/keyboard_shortcut_editor
Yours should be there too.
Go to that directory
cd ./.local/share/jupyter/nbextensions/
ls
You see full list of various extensions. Let's copy one of them into hide_copy:
cp -r hide_input hide_code
cd hide_code
ls
The important file there is main.js. Replace it with that hide_code.js from ~./ipython
cp ~./ipython/hide_code.js ./main.js
Rename hide-input.yaml with hide-code.yaml and edit the content accordingly. Mainly, replace all Hide_Input references to Hide_Code. You can edit readme.md as well, but that doesn't matter. Because, the main thing, you created a new extension.
Now, if you launch your jupyter and go to http://localhost:8888/nbextensions, you will see Hide Code. And if click on that checkbox, it's on. Here are snapshots:
It is a weird sequence. But it worked for me. And the main thing, it puts it right where it needs to be. Hide_code actually needs to be a part of Nbextensions. I don't know why it is not. That way it's easy to turn it on and off any way you like it.
As described in the documentation: https://github.com/kirbs-/hide_code, you can troubleshoot by running the following code with appropriate Jupyter config directory location:
import hide_code.hide_code as hc
dir = "<full path to Jupyter config directory>"
hc.install(dir)

Cannot locate json connection file created by ipython kernel

I'm using ipython 4.1.2 (installed via Anaconda). I locate the profile location (which is the default)
ipython locate profile
/home/myname/.ipython/profile_default
ipython kernel runs fine, saying
To connect another client to this kernel, use:
--existing kernel-8664.json
However, when I look inside /home/myname/.ipython/profile_default/security, it is entirely empty.
What's the issue here?
Connection files now live in a different location, because they are a component of the Jupyter architecture, rather than an IPython specific thing. The exact location depends on your system, but you can find it by running:
jupyter --runtime-dir
Or in Python code, call:
jupyter_core.paths.jupyter_runtime_dir()

How to autosave ipython notebook

Does anyone know if there's an option (or a suggested hack) to make IPython notebooks save automatically before executing a cell?
Many times I've been working on something without saving for quite some time, then I execute a stupid command that prints so much crap to the console that my browser becomes unresponsive, leading to me losing all my work.
A timed autosave might also do the trick.
The development version has that feature fully implemented. Install it by following the instructions on the ipython github.
Instructions form the repo:
If you want to hack on certain parts, e.g. the IPython notebook, in a
clean environment (such as a virtualenv) you can use pip to grab the
necessary dependencies quickly:
$ git clone --recursive https://github.com/ipython/ipython.git
$ cd ipython
$ pip install -e ".[notebook]"
This installs the necessary
packages and symlinks IPython into your current environment so that
you can work on your local repo copy and run it from anywhere:
$ ipython notebook
Updating iPython Notebook solved several problems I had with iPython Notebook; for instance, it autosaves, or auto-correction is disabled, or %matplotlib inline works now (before updating, I had to use --pylab inline in the command line when I was running $ipython notebook).
As I use coda on my mac, I updated iPython Notebook via conda:
$conda update ipython
You could simply set a lower interval for autosave feature using the following magic command:
%autosave 60
in order to save automatically your notebook every 60 seconds.

Display of music21, musicXML PNG objects using iPython Notebook/Enthought Canopy

I am experimenting with the music21 library, in preparation for a Machine Learning project that involves genre classification and categorization. I and following some tutorials available here. I am using MuseScore as my MusicXML program, and I am trying to run the whole thing from iPython.
Although I can run the some of the turtorials from the terminal, some elements don't seem to run well from inside iPython. For example:
In [3]: sBach.show()
Out[3]: <music21.ipython21.objects.IPythonPNGObject at 0x10da0aa10>
The line above shows that the PNG object is created, but not displayed. The expected output for 3 above is the following:
Experimenting with the following iPython command, I get a placeholder for an image, but not image.
In [6]: %load_ext music21.ipython21.ipExtension
In [7]: sBach.show()
I can't find any problem with my MusicXMLPath. This tutorial refers to the use of musc21 with Anaconda, but all my developments is done with Enthought, so I prefer not to run another virtual environment to use music21 with iPython.
Is there any way to run music21 in an Enthought/iPython notebook?
I have been grappling with this issue myself. ... Have you set your musicxmlPath in music21? If you have not, it's done via environment.set(key, value). You can query for available keys with environment.keys(). I hope this isn't too simple an answer, but it cleared up the problem for me.
This should be in the iPython music21 documentation somewhere, my apologies: iPython in music21 requires Lilypond to be installed for images to be generated within the notebook itself. There hasn't been (and won't be until MuseScore 2.0 is released) a way using MusicXML to generate PNG images of scores directly.
Edit: 2015 July; music21 2.0 w/ MuseScore 2 will generate the PNG images with MuseScore if it is installed and fallback to Lilypond if it is not installed.
If not yet tried, some steps to isolate the cause of the problem:
1) Update to the latest Canopy (Edit: currently 1.4.1) (might help this, will help generally, won't hurt).
2) Change the Pylab backend in Canopy's IPython shell to "Inline (SVG)", via Preferences / Python. (The default Qt backend in that shell conflicts with music21's use of the tkinter library.)
3) Test your script in that shell rather than in the notebook.
4) Ensure that Canopy User Python is your default Python in a Terminal window, as described here.
5) Test your scripts inside of plain ipython terminal (from Terminal, type ipython).
6) Test in ipython terminal in pylab mode (ipython qtconsole --pylab=inline).
7) Test your scripts inside of ipython notebook running in a regular browser (from Terminal, type ipython notebook, and/or ipython notebook --pylab=inline).
Had similar issues before. It's the same problem when people try to use plot function in ipython/jupyter notebook. You need to call
%matplotlib inline
For me the issue was solved by uninstalling the snap version of musescore and installing it from ppa:mscore-ubuntu/mscore3-stable via https://launchpad.net/~mscore-ubuntu/+archive/ubuntu/mscore3-stable