You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Until now we've worked with Python either directly via the interactive Python console, or by writing Python programs using a text
11
11
editor.
12
12
13
-
However, there are other ways to work with Python. [IPython](http://ipython.org/) is a set of tools originally developed to make it easier for scientists to work with Python and data. It allows you to combine interactive Python exploration with prewritten programs and even text and equations for documentation.
13
+
However, there are other ways to work with Python. [Jupyter](http://jupyter.org/) is a set of tools originally developed to make it easier for scientists to work with Python and data. It allows you to combine interactive Python exploration with prewritten programs and even text and equations for documentation.
14
14
15
-
*IPython isn't a different programming language, it's just a set of computer programs for working with the Python language.*
15
+
*Jupyter isn't a different programming language, it's just a set of computer programs for working with the Python language.*
16
16
17
-
## Sneak Preview of IPython
17
+
## Sneak Preview of Jupyter
18
18
19
-
![A sample from the IPython Notebook introduction examples][ipn-example]
19
+
![A sample from the Jupyter Notebook introduction examples][ipn-example]
20
20
21
-
(This is just an example of what IPython Notebook can do, don't feel like you need to understand it just yet! If you want to type it into IPython Notebook later on, type the special command `%matplotlib inline` before you start - there's an explanation coming up in the Charts chapter.)
21
+
(This is just an example of what Jupyter Notebook can do, don't feel like you need to understand it just yet! If you want to type it into Jupyter Notebook later on, type the special command `%matplotlib inline` before you start - there's an explanation coming up in the Charts chapter.)
22
22
23
-
# Installing IPython Notebook
23
+
# Installing Jupyter Notebook
24
24
25
-
There are a number of ways to install IPython Notebook.
25
+
There are a number of ways to install Jupyter Notebook.
26
26
27
-
If you're using OS X or Windows, we recommend you download and install [Anaconda](http://continuum.io/downloads.html), which is a free bundled installer of Python together with many other useful tools (including IPython Notebook.)
27
+
If you're using OS X or Windows, we recommend you download and install [Anaconda](http://continuum.io/downloads.html), which is a free bundled installer of Python together with many other useful tools (including Jupyter Notebook.)
28
28
29
29
**Anaconda is a fairly large (around 300Mb) download so if you're at a workshop event we'll have some USB keys with the predownloaded installers to save on bandwidth**
30
30
31
-
Anaconda comes with its own version of Python 2.7, IPython Notebook, plus other libraries like matplotlib and a package manager ("conda") that you can use to install other packages or other Python versions.
31
+
Anaconda comes with its own version of Python 2.7, Jupyter Notebook, plus other libraries like matplotlib and a package manager ("conda") that you can use to install other packages or other Python versions.
32
32
33
33
If you're using Linux, Anaconda is available as an option but we recommend you try to install the programs using your Linux distribution instead (see under "Alternative Options", below.)
34
34
@@ -38,84 +38,84 @@ If you're using Linux, Anaconda is available as an option but we recommend you t
38
38
39
39
Anaconda (described above) is the easiest option for this workshop. There are some other installer options that you can test out if you'd like to try something different:
40
40
41
-
* If you're on Linux, most package managers include IPython Notebook. For instance on Ubuntu or Debian:
41
+
* If you're on Linux, most package managers include Jupyter Notebook. For instance on Ubuntu or Debian:
* If you have 'pip' installed (maybe from another OTS workshop) then you may be able to install IPython by itself (plus matplotlib) via 'pip', as follows:
45
+
* If you have 'pip' installed (maybe from another OTS workshop) then you may be able to install Jupyter by itself (plus matplotlib) via 'pip', as follows:
46
46
47
-
pip install ipython[notebook]
47
+
pip install jupyter
48
48
49
49
(If you're on OS X you may need Xcode to compile dependencies.)
50
50
51
-
* If you can't get IPython Notebook to work on your computer at all, there's a hosted service called [Wakari](https://www.wakari.io/) that you can use for free. In this case your programs won't be running on your own computer, they'll be running "in the cloud" (i.e. on Wakari's servers somewhere else) and you'll just see the results in your web browser.
51
+
* If you can't get Jupyter Notebook to work on your computer at all, there's a hosted service called [Wakari](https://www.wakari.io/) that you can use for free. In this case your programs won't be running on your own computer, they'll be running "in the cloud" (i.e. on Wakari's servers somewhere else) and you'll just see the results in your web browser.
52
52
53
53
## Note about Python 3
54
54
55
55
Anaconda and some of the other installers come with Python version 2. You may have been using Python version 3 up until now, this is the version that the Introduction to Programming workshop encourages you to use.
56
56
57
-
The Python world is slowly migrating towards using Python 3 for everything. IPython is available for both 2 & 3, but Anaconda comes with Python 2 as it includes some components which are still Python 2 only.
57
+
The Python world is slowly migrating towards using Python 3 for everything. Jupyter is available for both 2 & 3, but Anaconda comes with Python 2 as it includes some components which are still Python 2 only.
58
58
59
59
Python 2 and Python 3 have some minor incompatible differences in language syntax. The programs shown in this workshop are designed to work with both, but if you find some code that doesn't work (but perhaps works on your neighbour's computer) then this may be why.
60
60
61
61
62
-
## Starting IPython Notebook
62
+
## Starting Jupyter Notebook
63
63
64
-
You interact with IPython Notebook using your web browser. The Notebook program creates a "web server" locally on your computer that you then connect to.
64
+
You interact with Jupyter Notebook using your web browser. The Notebook program creates a "web server" locally on your computer that you then connect to.
65
65
66
-
On Windows, you can find a launcher for IPython Notebook under Anaconda in the Start menu.
66
+
On Windows, you can find a launcher for Jupyter Notebook under Anaconda in the Start menu.
67
67
68
-
On Linux or OS X, you can start IPython Notebook from the command line. First open a terminal window, use 'cd' to navigate to the directory where you want to store your Python files and notebook document files. Then run this command:
68
+
On Linux or OS X, you can start Jupyter Notebook from the command line. First open a terminal window, use 'cd' to navigate to the directory where you want to store your Python files and notebook document files. Then run this command:
69
69
70
-
ipython notebook
70
+
jupyter notebook
71
71
72
72
You should see some output like this:
73
73
74
74
[NotebookApp] Using existing profile dir: u'/home/gus/.ipython/profile_default'
75
75
[NotebookApp] Serving notebooks from /home/gus/workshops
76
-
[NotebookApp] The IPython Notebook is running at: http://127.0.0.1:8888/
76
+
[NotebookApp] The Jupyter Notebook is running at: http://127.0.0.1:8888/
77
77
[NotebookApp] Use Control-C to stop this server and shut down all kernels.
78
78
79
-
A browser window may automatically open showing the IPython Notebook interface. If it doesn't open, you can copy-paste the "http" address from the output and paste it into your browser.
79
+
A browser window may automatically open showing the Jupyter Notebook interface. If it doesn't open, you can copy-paste the "http" address from the output and paste it into your browser.
80
80
81
-
Even though you're interacting with IPython Notebook using your browser, Notebook is running right there on your computer in that window. Only you have access to it.
81
+
Even though you're interacting with Jupyter Notebook using your browser, Notebook is running right there on your computer in that window. Only you have access to it.
82
82
83
83
84
84
## First Steps with Notebook
85
85
86
86
In your browser, click the "New Notebook" button and a new notebook will open up.
87
87
88
-
![IPython Notebook empty][ipn-empty]
88
+
![Jupyter Notebook empty][ipn-empty]
89
89
90
90
The empty box at the top is the first "cell" for entering Python code.
91
91
92
92
Try typing something like `print("Hello World")` into the cell. To run the code in the cell and see the output, click the Run button (play icon) on the toolbar, or type Shift-Enter:
93
93
94
-
![IPython Notebook Hello World][ipn-hello]
94
+
![Jupyter Notebook Hello World][ipn-hello]
95
95
96
96
You'll see that whenever you run a cell, a new empty cell appears where you can enter another set of Python statements. Try assigning a variable. Let's make another shopping list:
97
97
98
-
![IPython Notebook Assign Variable][ipn-variable]
98
+
![Jupyter Notebook Assign Variable][ipn-variable]
99
99
100
100
When you Run this cell you won't see any output, but behind the scenes the variable "shopping list" has been assigned.
101
101
102
102
We can see this by making a third cell to print the contents:
103
103
104
-
![IPython Notebook Print Shopping List][ipn-list]
104
+
![Jupyter Notebook Print Shopping List][ipn-list]
105
105
106
-
You can do anything with IPython Notebook cells that you'd do with normal Python code. As you build up the notebook full of cells you create a history of the things you've done and the results that were printed.
106
+
You can do anything with Jupyter Notebook cells that you'd do with normal Python code. As you build up the notebook full of cells you create a history of the things you've done and the results that were printed.
107
107
108
-
## IPython Notebook Directory
108
+
## Jupyter Notebook Directory
109
109
110
-
When IPython Notebook starts up it prints a line like this:
110
+
When Jupyter Notebook starts up it prints a line like this:
111
111
112
112
[NotebookApp] Serving notebooks from /home/gus/workshops
113
113
114
114
This is the directory that it was started from, and it's the working directory for loading Python files, text files, etc.
115
115
116
116
It can be helpful to make sure this directory is the directory where you plan to keep files related to your work.
117
117
118
-
On Windows with Anaconda this directory is called "IPython Notebooks" inside "My Documents", and is created when you install Anaconda. On OS X, Linux or other Windows installations it's up to you which directory you use.
118
+
On Windows with Anaconda this directory is called "Jupyter Notebooks" inside "My Documents", and is created when you install Anaconda. On OS X, Linux or other Windows installations it's up to you which directory you use.
119
119
120
120
If you're launching from the command line, you can 'cd' to this directory before you launch Notebook.
121
121
@@ -124,48 +124,48 @@ If you're using the command line on Windows, you can use Explorer to find your d
124
124
125
125
## Loading Notebook Files
126
126
127
-
You can also load IPython Notebooks that other people have created, saved as IPython Notebook files (File extension .ipynb.) Try [downloading and opening this Notebook file with the shopping list example](../files/shopping_list.ipynb).
127
+
You can also load Jupyter Notebooks that other people have created, saved as Jupyter Notebook files (File extension .ipynb.) Try [downloading and opening this Notebook file with the shopping list example](../files/shopping_list.ipynb).
128
128
129
-
After you download the Notebook file, move it into your IPython Notebook working directory and then choose File -> Open in Notebook to open it.
129
+
After you download the Notebook file, move it into your Jupyter Notebook working directory and then choose File -> Open in Notebook to open it.
130
130
131
131
That Notebook contains some additional code, and some suggestions for changes you can make by going back and editing the existing files. Take a few moments to play with the Notebook - rerun the cells, edit the cells to change them, don't be afraid to break things!
132
132
133
133
## Loading Python Files
134
134
135
-
You can also load a pre-existing Python file into an IPython Notebook cell by typing
135
+
You can also load a pre-existing Python file into an Jupyter Notebook cell by typing
136
136
137
137
%load "myprogram.py"
138
138
139
139
Into a cell and running it. This loads up a new cell containing the contents of *myprogram.py*.
140
140
141
-
Test this feature out by loading one of the scripts you wrote during the recap session. You may have to specify the full path to the script file, depending on the directory IPython Notebook started up from.
141
+
Test this feature out by loading one of the scripts you wrote during the recap session. You may have to specify the full path to the script file, depending on the directory Jupyter Notebook started up from.
142
142
143
143
There is one other useful built-in tool for working with Python files:
144
144
145
145
%run "myprogram.py"
146
146
147
147
This will run *myprogram.py* and load the output into a Notebook cell.
148
148
149
-
## Other IPython tips
149
+
## Other Jupyter tips
150
150
151
151
* As well as Shift-Enter there are other keyboard shortcuts in Notebook. Look under the Help menu -> Keyboard Shortcuts to see them all.
152
152
153
-
* In previous workshops we used `help()` to view help information in the Python interpreter. IPython Notebook makes this even simpler, you can just type the name of a Python function or module and end it with a `?`. Try it now, type `range?` into a cell and run it.
153
+
* In previous workshops we used `help()` to view help information in the Python interpreter. Jupyter Notebook makes this even simpler, you can just type the name of a Python function or module and end it with a `?`. Try it now, type `range?` into a cell and run it.
154
154
155
-
* Using a nifty tool called NBViewer you can easily share IPython Notebooks on the internet, rendered as web pages (but still downloadable to play with in IPython.) Check out the [NBViewer home page](http://nbviewer.ipython.org/) or the [IPython Notebook gallery](https://github.com/ipython/ipython/wiki/A-gallery-of-interesting-IPython-Notebooks) for some interesting ones.
155
+
* Using a nifty tool called NBViewer you can easily share Jupyter Notebooks on the internet, rendered as web pages (but still downloadable to play with in Jupyter.) Check out the [NBViewer home page](http://nbviewer.jupyter.org/) or the [Jupyter Notebook gallery](https://github.com/jupyter/jupyter/wiki/A-gallery-of-interesting-Jupyter-Notebooks) for some interesting ones.
156
156
157
-
## Other Ways to Run IPython
157
+
## Other Ways to Run Jupyter
158
158
159
159
Other options if you feel like exploring:
160
160
161
-
* There is a command line "ipython" program (just run `ipython` without the --notebook argument) that behaves similarly to the "python" interactive shell, but with some of the nice features of IPython Notebook (although none of the graphical features.)
161
+
* There is a command line "ipython" program (just run `ipython` without the --notebook argument) that behaves similarly to the "python" interactive shell, but with some of the nice features of Jupyter Notebook (although none of the graphical features.)
162
162
163
-
* There is a graphical IPython program (ie not web browser based) called "IPython QtConsole". It's like the command line IPython but with some graphical features. Launch this one by running `ipython qtconsole`.
163
+
* There is a graphical Jupyter program (ie not web browser based) called "Jupyter QtConsole". It's like the command line Jupyter but with some graphical features. Launch this one by running `jupyter qtconsole`.
164
164
165
165
166
-
## Doing the workshop without IPython
166
+
## Doing the workshop without Jupyter
167
167
168
-
Tried out IPython Notebook but don't really like it? No problem! The rest of the workshop can be completed without using IPython Notebook at all, feel free to go back to the Python coding tools you were using already.
168
+
Tried out Jupyter Notebook but don't really like it? No problem! The rest of the workshop can be completed without using Jupyter Notebook at all, feel free to go back to the Python coding tools you were using already.
169
169
170
170
## Next Chapter
171
171
@@ -176,4 +176,3 @@ Time to give Notebook a real workout! The next chapter is [Working With Text Fil
0 commit comments