View Single Post
Posts: 1,269 | Thanked: 3,961 times | Joined on May 2011 @ Brazil
#1
IPython is an enhanced Python interactive shell.

IPython package is available to MeeGo 1.2 Harmattan, so interactively using Python and its modules (like SymPy, NumPy, MatPlotLib, etc) becomes a lot easier.

See the "IPython for Maemo 4 & 5 & 6" topic in Talk Maemo.org for Maemo 4 Diablo and Maemo 5 Fremantle versions of IPython 0.10.2, which is the latest version compatible with Python 2.5 (so Maemo 4 & 5 can't have IPython >= 0.11).

There are 3 versions to choose to install on MeeGo Harmattan :
- IPython 0.13.2 (new, released in 15/06/2013, available in my Harmattan repository);
- IPython 0.10.2 (13/11/2011, 1.9 MB);
- IPython 0.10 (from Nokia repositories since 14/12/2011).

IPython 0.13 x 0.10.2 x IPython 0.10 packages :
- v0.13 for MeeGo Harmattan also has QtConsole and Notebook web interfaces, so MeeGo Harmattan is the only smartphone mobile OS which runs IPython QtConsole & Notebook;
- v0.13.2 is newer (05/04/2013) than v0.10.2 (09/04/2011) and v0.10 (04/07/2009);
- see the detailed differences in "What's New in IPython" in IPython site;
- v0.13 package takes from 5.5 MB (IPython terminal console) to 150 MB (complete IPython with Notebook & Qt console) after install, while v0.10.2 uses 8.0 MB and v0.10 only 6.6MB;
- optional IPython-doc v0.13.2 with examples and documentation takes 19.0 MB after install;
- v0.13 takes approx. 2.5s to open on a Nokia N9 @ 1 GHz, compared to about 1.4s for v0.10/0.10.2;
- v0.13 can be installed by enabling my Harmattan repository and installing via "apt-get install" or "MeeCatalog";
- v0.10.2 can be installed by tapping the .deb file (without using Terminal & apt-get install), after manual download;
- v0.10 is official from Nokia repositories;
- v0.13 & v0.10.2 are maintained and packaged for MeeGo Harmattan by me.

Version history :
- IPython 0.13.2 (05/04/2013) released for MeeGo Harmattan (15/06/2013), an upstream bug fix version of v0.13;
- IPython 0.13.1-3 Harmattan release (12/02/2013), a bug fix version for using Qt console;
- IPython 0.13.1-2 Harmattan release (22/01/2013), first release including Qt console and Notebook interfaces on MeeGo Harmattan;
- IPython 0.13.1-1 (21/10/2012) released for MeeGo Harmattan (06/01/2013), with only terminal interface;
- IPython 0.10.2 (09/04/2011) released for MeeGo Harmattan (13/11/2011), with only terminal interface.

Screenshots of IPython on a Nokia N9

Tapping the IPython icon or typing ipython on Terminal, then programming a little bit :


IPython Notebook 0.13.1 with Firefox (Fennec) v15 :


IPython Qt console 0.13.1 :


Application manager information about IPython Notebook 0.13.1-2, which takes 146 MB of installed files (but 134 MB due to MathJax for showing mathematical expressions) :


Installing IPython on MeeGo Harmattan

IPython 0.13.2-1 Harmattan can be easily installed by using my Harmattan repository. After configuring it, use :
- "MeeCatalog", searching for IPython there are IPython, IPython Notebook and IPython Qt console to choose, where IPython is installed by IPython Notebook and IPython Qt console;
- or Terminal as root :
# apt-get install ipython
or
# apt-get install ipython-notebook
or
# apt-get install ipython-qtconsole
or
# apt-get install ipython-notebook ipython-qtconsole
IPython terminal console uses 5.5 MB; IPython Notebook and IPython takes 146 MB (with 134 MB used by MathJax for displaying mathematical expressions on IPython Notebook); IPython Qt console and IPython uses 10 MB; IPython full installation (IPython Notebook, IPython Qt console and IPython) takes a total of 150 MB.

IPython 0.10.2 has manual download of the .deb package :
ipython_0.10.2-1harmattan1_all.deb (1.9 MB)
Using a file manager, tap in the file to install it.

IPython 0.10 is available in Nokia repositories, so to install use the Terminal, then become root by typing :
$ devel-su
and the 'rootme' password, then type :
# apt-get install ipython
confirming the installation.

The IPython installation also needs (and installs if not installed) Python/Python-Support packages (23 MB), but they are also used by other softwares.

Using IPython on MeeGo Harmattan

For all versions (0.10, 0.10.2 and 0.13), to use IPython terminal interface, type :
$ ipython
Time to open is about 2.5 s, or 4.5 s by tapping the icon in v0.13.
If you have PyLab (NumPy and MatPlotLib, see the topic "MatPlotLib - 2D & 3D plots for MeeGo Harmattan") installed, to load PyLab in interactive mode :
$ ipython --pylab
If you have SymPy installed, see the topic "SymPy (Computer Algebra System) for Maemo 4 & 5 & 6", to load SymPy in interactive mode :
$ isympy
or (for v0.13) :
$ ipython --profile=sympy

IPython 0.13 only :
After full installation, there are 3 new icons for : IPython, IPython Notebook (IPy Notebook) and IPython Qt console (IPy QtConsole).


IPython 0.13 terminal interface : tap the IPython icon. You can have many IPython consoles open at the same time. Or use the Terminal to start IPython, see above.

IPython 0.13 Qt console : tap the "IPy QtConsole" icon, it takes approx. 9.7 s to open. It has a Qt GUI with very small fonts, but it works very well. Hints :
- use menu "View -> Zoom In (Ctrl + +)" 2-4 times to improve reading the text;
- use menu "View -> Full Screen (F11)";
- MeeGo virtual keyboard (vkb) works ! But it is opaque, so scroll the text up (with the vertical scroll bar or vertical keyboard arrows) so the vkb is not above the current text;
- use MeeGo vkb with arrows by installing "MesInput" (from Nokia Store) and choosing "English with arrows". Or use Swype vkb in edit keyboard mode, with arrows;
- the best usage is with external Bluetooth or N950 keyboard, so all keyboard shortcuts work, with Ctrl, Alt, etc. When using external Bluetooth keyboard, install and use "Empty VNC" vkb from "MesInput" (from Nokia Store);
- to load PyLab, type "%pylab", with inline plots, type "%pylab inline" (see the screenshot below);
- or use Terminal, e.g., "$ ipython qtconsole", "$ ipython qtconsole --pylab", "$ ipython qtconsole --pylab=inline", "ipython --profile=sympy".

IPython 0.13 Notebook : tap the "IPy Notebook" icon, taking 17s to open with Firefox v15 as default web browser. If "$BROWSER" variable has no content, it will show a Terminal with :
[NotebookApp] The IPython Notebook is running at: http://127.0.0.1:8888/
[NotebookApp] Use Control-C to stop this server and shut down all kernels.
[NotebookApp] No web browser found: could not locate runnable browser.
So you can open a web browser and point it to "http://127.0.0.1:8888/".

Or you can configure the $BROWSER variable by choosing one web browser, using Terminal and typing "export BROWSER=<pathname-to-web-browser>". To make this configuration automatic for :
- MeeGo Harmattan native web browser, type in Terminal :
$ echo 'export BROWSER=/usr/bin/grob' >> ~/.profile
- Fennec/Firefox from Nokia Store, type :
$ echo 'export BROWSER=/opt/fennec/lib/fennec-15.0/fennec' >> ~/.profile
- Opera Mobile, type :
$ echo 'export BROWSER=/opt/operamobile-labs/bin/operamobile-labs' >> ~/.profile
Then reboot your Nokia N9 so this configuration will take effect.

My analysis of the 3 above web browsers :
- Firefox mobile (v15) is the best one for IPython Notebook use, rendering MathJax (mathematical symbols) very well. Only issue is that vkb arrows don't work, as well as Bluetooth keyboard (haven't tried N950 keyboard) don't work at all;
- Grob (default web browser) has serious problem of not showing more than 1 page of the notebook... it is a pity because vkb arrows and Bluetooth keyboard work very well;
- Opera Mobile 12 doesn't render MathJax (mathematical symbols), sometimes tapping the Notebook menu doesn't work, its vkb doesn't have arrows, and Bluetooth keyboard has no arrows, backspace, shift-enter, etc working.

Snowshoe Qt5, Helium and UC Browser don't work with IPython Notebook.

Fennec-QML (using IPCLiteAPI) v0.0.1 shows promise : renders MathJax, doesn't zoom in/out automatically like Firefox, perfect use of keyboard (vkb or Bluetooth) so vkb arrows and shift+enter are ok, Bluetooth keyboard with all woking shortcuts. But it is unstable (closes sometimes), has problem scrolling long notebooks (only vertical arrows of Bluetooth keyboard work) and can't select "New Notebook" or "Cell" type.

Some hints for using (Firefox mobile v15 with) IPython Notebook on Nokia N9/N950 :
- change the focus to the menu (tap twice in the horizontal menu) to navigate over the notebook content. Or else it will zoom in/out, scroll and show the vkb automatically...
- to edit some non-code cell, convert the cell to code cell, edit, than change to the previous cell type. It is because double tapping is filtered by Firefox to zoom in/out, and double tapping is needed to edit non-code cells;
- portrait mode is better to type with the vkb because it uses less screen space;
- be patient when opening medium/large notebooks with many formulas, plots, etc. Firefox mobile is slow and Nokia N9/N950 has a Cortex A8 @ 1 GHz;
- to load PyLab, type "%pylab", with inline plots, type "%pylab inline" (see the screenshot below);
- or use Terminal, e.g., "$ ipython notebook", "$ ipython notebook --pylab", "$ ipython notebook --pylab=inline", "ipython notebook --profile=sympy", "ipython notebook --pylab=inline --profile=sympy". You can create a script for each case, or even a .desktop file in "/usr/share/applications".

IPython Notebook 0.13.2 on Nokia N9 can also run as a server for remote web clients (PC's, Nokia N900, Android devices, etc), see post #19.

IPython documentation :
- online in the IPython.org site;
- examples and HTML manual in "/usr/share/pyshared/IPython-doc/" after enabling my Harmattan repository and typing as root in Terminal :
$ apt-get install ipython-doc
which takes 19.0 MB.

Some features of the IPython interactive shell :
- tab (or ctrl+i) completion for objects;
- input history navigation using up (or Ctrl+p) and down (or Ctrl+n) arrows;
- search input history by typing partial input then up/down arrow to show matching lines, or ctrl+r to have a serch prompt;
- input line n can be retrieved using '_in', 'In[n]', '_ih[n]', and _i, _ii, _iii to access the previous, next previous and next-next previous inputs;
- output line n can be retrieved using '_n', 'Out[n]', '_oh[n]', and _, __, ___ access the previous, next previous and next-next previous outputs;
- information about objects using '?word' or 'word?', full information with '??word' or 'word??';
- magic command system, like '%run file.py', '%pwd';
- run system commands with '!' as prefix, e.g., '!ls".
More details in :
IPython interactive tutorial
IPython Interactive Reference
__________________
Python, C/C++, Qt and CAS developer. For Maemo/MeeGo/Sailfish :
Integral, Derivative, Limit - calculating mathematical integrals, derivatives and limits. SymPy - Computer Algebra System.
MatPlotLib - 2D & 3D plots in Python. IPython - Python interactive shell.
-- My blog about mobile & scientific computing ---
Sailfish : Sony Xperia X, Gemini, Jolla, Jolla C, Jolla Tablet, Nexus 4. Nokia N9, N900, N810.

Last edited by rcolistete; 2013-06-16 at 06:40. Reason: IPython 0.13.2 released
 

The Following 15 Users Say Thank You to rcolistete For This Useful Post: