IPython is an enhanced Python shell, the shell being the prompt which appears when you start python command in your terminal. IPython comes with notebook flavour, where IPython Notebook presents the modern HTML-based shell for Python.
Table Of Content
Python is so-called dynamic programming language where much can be achieved by piloting your code in an interactive interpreter or tuning your production server from the shell. Basing the read-evaluate-print-loop (REPL) to web browser technology, instead of terminal technology, brings shell usability to the modern age, boosting your working efficiency considerably.
First create a virtualenv. Then continue in the activated virtualenv.
Install IPython with IPython Notebook extensions:
pip install "ipython[notebook]"
Starting IPython in terminal:
Developers like their terminals either white-on-black or black-on-white. Try switching the color scheme:
3. Enter the HTML
Now comes the big one. Start IPython notebook for a web browser based shells:
This will start IPython kernel running in the port localhost:8888 and automatically connects your default web browser into it.
Yay! Finally you can
- Use shift and arrows to select your text, unlike in most of the terminals
- Copy-paste that works 100%
- Click things with mouse and place your edit cursor
- Save and replay your shell sessions
- Output graphics directly from the shell
4. Django integration
Install Django Extensions package. Django Extensions, with many other features, gives you the ability to automatically import all of your application models on the start up to have quicker access to them. We do the example below using DjangoGirls website checkout.
pip install django_extensions
Add django_extensions to Django settings INSTALLED_APPS list:
INSTALLED_APPS = ( .... 'django_extensions' )
Start IPython-enabled Django shell through Django extensions command:
python manage.py shell_plus
And you can straight away play with your Django models:
Now, try entering to the Notebook Django shell:
python manage.py shell_plus --notebook
… and you get the same, but with all IPython Notebook goodies:
5. Running IPython Notebook on your server
IPython Notebook uses, by default, uses localhost TCP/IP sockets to allow web browsers to connect to IPython Notebook kernel.