Seite - 215 - in Programming for Computations – Python - A Gentle Introduction to Numerical Simulations with Python
Bild der Seite - 215 -
Text der Seite - 215 -
A.5 WritingIPythonNotebooks 215
A.4.2 Basic IntrotoWakari
After having logged in at thewakari.io site, you automatically enter an IPython
notebookwith a short introduction to how the notebook can be used. Click on
the New Notebook button to start a new notebook. Wakari enables creating and
editingplainPythonfiles too: clickon theAddfile icon inpane to the left,fill in the
programname, and you enter an editorwhere you canwrite a program. Pressing
Execute launches an IPython session in a terminalwindow,whereyoucan run the
programby run prog.py if prog.py is the name of the program. To download
thefile, selecttest2.py in the left paneandclickon theDownloadfile icon.
There isapull-downmenuwhereyoucanchoosewhat typeof terminalwindow
youwant: aplainUnix shell, an IPythonshell, or an IPythonshellwithMatplotlib
forplotting.Using the latter,youcanrunplainPythonprogramsorcommandswith
graphics. Justchoosethetypeofterminalandclickon+Tab tomakeanewterminal
windowof thechosen type.
A.4.3 InstallingYourOwnPythonPackages
Both SageMathCloud andWakari let you install your own Python packages. To
install anypackagepackagenameavailableatPyPi15, run
Terminal
pip install --user packagename
To install theSciTools package,which is usefulwhenworkingwith this book, run
thecommand
Terminal
pip install --user -e \
git+https://github.com/hplgit/scitools.git#egg=scitools
A.5 WritingIPythonNotebooks
The IPython notebook is a splendid interactive tool for doing science, but it can
also be used as a platform for developing Python code. You can either run it
locally on your computer or in aweb service like SageMathCloudorWakari. In-
stallation on your computer is trivial on Ubuntu, just sudo apt-get install
ipython-notebook, and also onWindowsandMac16 by usingAnacondaorEn-
thoughtCanopyfor thePython installation.
The interface to the notebook is aweb browser: youwrite all the code and see
all the results in thebrowserwindow. There are excellentYouTubevideosonhow
to use the IPython notebook, so here we provide a very quick “step zero” to get
anyonestarted.
15https://pypi.python.org/pypi
16http://ipython.org/install.html
Programming for Computations – Python
A Gentle Introduction to Numerical Simulations with Python
- Titel
- Programming for Computations – Python
- Untertitel
- A Gentle Introduction to Numerical Simulations with Python
- Autoren
- Svein Linge
- Hans Petter Langtangen
- Verlag
- Springer Open
- Datum
- 2016
- Sprache
- englisch
- Lizenz
- CC BY-NC 4.0
- ISBN
- 978-3-319-32428-9
- Abmessungen
- 17.8 x 25.4 cm
- Seiten
- 248
- Schlagwörter
- Programmiersprache, Informatik, programming language, functional, imperative, object-oriented, reflective
- Kategorie
- Informatik