Ipython
Now Jupyter
Try online Jupyter


Jupyter talk by Fernando Perez (Video



Scientific python lectures

kernels

Install python2 and python3 notebooks
[+]
Installation based in pip2 and pip3. First we must sure to use the unpackaged versions of pip.
Then
We must now install jupyter < 6 with support for python2 kernel
To install the python2 kernel
And each user must activate the kernel at user level:
Without the --user option the installation is sytem wide
Once is launched, the two kernel could appear as available.
# apt-get remove python-pip python2-pip
Then
# aptitude install python-setuptools python3-setuptools python-dev python3-dev # easy_install-2.7 pip # easy_install3 pip
We must now install jupyter < 6 with support for python2 kernel
# pip3 install notebook
To install the python2 kernel
# pip2 install ipykernel
And each user must activate the kernel at user level:
$ python2 -m ipykernel install [--user]
Once
$ jupyter notebook
Install jupyterhub
[+]
Install and use according to the following script (https://github.com/jupyterhub/jupyterhub/blob/master/README.md)
jupyterhub.sh
#!/usr/bin/env bash #=== INSTALLATION === # # pip3 install --upgrade notebook # JupyterHub can be installed with pip, and the proxy with npm: # # npm install -g configurable-http-proxy # # pip3 install jupyterhub #=== CERTIFICATE GENERATION: === # From: https://workaround.org/ispmail/jessie/create-certificate # # openssl req -newkey rsa:4096 -nodes -sha512 -x509 -days 3650 -nodes -out /etc/ssl/certs/mailserver.pem -keyout /etc/ssl/private/mailserver.pem # On "Common Name" use the hostname, e.g, www.yourserver.com #=== LAUNCH COMMAND as root: === jupyterhub --port 4443 --ssl-key /etc/ssl/private/mailserver.pem --ssl-cert /etc/ssl/certs/mailserver.pem
Install jupyter extensions:
[+]Install (old)
[+]
The official updated documentation: Jupyter Kernels
.
To global install work inor something like this. The examples below are local installations. If the kernel is official can be installed as or See discussion here
. Or this
other thread
See kernels
:
o mejor el oficial de http://try.jupyter.org

To global install work in
/usr/local/share/jupyter/kernels
python2 -m IPython kernelspec install-self
python3 -m IPython kernelspec install-self


Cita:
You can perfectly run IPython 3 with Python 3 and kernels on Python 2.
for the time being you will need to install IPython notebook with python 2 and issue a
$ ipython2 kernelspec install-self
This will make the IPython2 kernel available with IPython3 server running on python 3.
for the time being you will need to install IPython notebook with python 2 and issue a
$ ipython2 kernelspec install-self
This will make the IPython2 kernel available with IPython3 server running on python 3.
See kernels

$ cat ~/.ipython/kernels/ir/kernel.json {"argv": ["R","-e","IRkernel::main()","--args","{connection_file}"], "display_name":"R" }
$ cat ~/.ipython/kernels/python2/kernel.json { "display_name": "Python 2", "language": "python", "codemirror_mode": { "version": 3, "name": "ipython" }, "argv": [ "/usr/bin/python", "-c", "from IPython.kernel.zmq.kernelapp import main; main()", "-f", "{connection_file}" ] }
o mejor el oficial de http://try.jupyter.org

jovyan@374b5bfac0c6:~$ cat /usr/local/share/jupyter/kernels/python2/kernel.json { "display_name": "Python 2", "language": "python", "argv": [ "/usr/bin/python2", "-m", "IPython.kernel", "-f", "{connection_file}" ] }
Parallel Ipython
[+]Ipython notebook with pylab support
[+]$ ipython notebook --InlineBackend.figure_format=svg
and in the first Ipython cell:
%pylab inline
Ipython notebook server
[+]Fast way
[+]
Listen all the interfaces
How to setup an ipython notebook server with the '%pylab inline' already active in Debian Wheezy. We assume that you have a full SciPy? installation as expalined in ubuntu.sh.
Instructions based in this tutorial
ipython notebopok --ip=*
How to setup an ipython notebook server with the '%pylab inline' already active in Debian Wheezy. We assume that you have a full SciPy? installation as expalined in ubuntu.sh.
Instructions based in this tutorial

Configuring the notebook server
- First, get your password hashed with IPython utility (From the terminal console!).
In [1]: from IPython.lib import passwd In [2]: passwd() Enter password: Verify password:
- Next, create a new IPython configuration profile.Uncomment and edit the following lines in the IPython profile config file - ~/.ipython/profile_myserver/ipython_notebook_config.py
$ ipython profile create myserver $ vim ~/.ipython/profile_myserver/ipython_notebook_config.py
c = get_config() c.IPKernelApp.pylab = 'inline' c.NotebookApp.ip = '*' c.NotebookApp.open_browser = False c.NotebookApp.password = u'sha1:yourhashedpassword' c.NotebookApp.port = 9999
- In order to guarantee a secure conection a certificate must be created
$ openssl req -x509 -nodes -days 365 -newkey rsa:1024 -keyout mycert.pem -out mycert.pem
- Running the server: now, you can run the server, to keep it running, you can manage the process with Supervisor
.
To check if inline chart works, just type that line in your new notebook at https://your.site:9999 (note the https protocol)$ ipython notebook --profile=myserver --certfile=mycert.pem
In [1]: plot(arange(10)) Out[1]: [<matplotlib.lines.Line2D at 0x39c8e50>]
Ipython in-depth
[+]2012-FSF award
[+]Ipython notebook: how to insert a link to a local file into a markdown cell?
[+]
The path need to be relative to where the server has been started, and prefixed with files/. e.g:
[PDF](files/workingdir/output.pdf)
Ipython notebook: make output cells like markdown
[+]from IPython.core.display import HTML def foo(): raw_html = "<h1>Yah, rendered HTML</h1>" return HTML(raw_html) foo()

Ipython notebook: display HTML code (as a cell output):
[+]
See http://stackoverflow.com/a/13770691/2268280
or simply:

from IPython.core.display import HTML def foo(): raw_html = "<h1>Yah, rendered HTML</h1>" return HTML(raw_html) foo()
from IPython.core.display import HTML raw_html = "<h1>Yah, rendered HTML</h1>" HTML(raw_html)
Yah, rendered HTML
Save notebook as LaTeX/PDF
[+]- File -> Download as reST (.rst)
in your terminal
$ pandoc -s file.rst -t latex -o file.tex
$ sudo apt-get install pandoc
Install in Debian 7 (Wheezy)
[+]
In Debian 8 use pip3 and the default instructions.
Install npm from here
: and follow the instructions
:
Install npm from here

# curl -sL https://deb.nodesource.com/setup | bash - # apt-get install -y nodejs # #or directly from: http://gfif.udea.edu.co/downloads/nodejs_0.10.36-1nodesource1~wheezy1_amd64.deb

# sudo apt-get install npm nodejs-legacy # npm install -g configurable-http-proxy # pip install ipython --upgrade # pip install ipython --upgrade # pip install pyzmq --upgrade # pip install tornado --upgrade # pip install jsonschema
Use Ipython Cell as optional editor
[+]
The Ipython Cells have its own sys.argv. The following check for Ipython before call sys.argv
#######IPYTHON CELL ####### [#]%%writefile run.py #!/usr/bin/env python CODE def run_from_ipython(): try: __IPYTHON__ return True except NameError: return False if not run_from_ipython() and len(sys.argv)>1: CODE