notebooks
notebooks copied to clipboard
IPython Notebooks from Various Presentations
notebooks
IPython Notebooks by Scott Sanderson
Running IPython Notebook
Assuming you have the below dependencies installed, you can run a local notebook server by running:
ipython notebook --matplotlib=inline --notebook-dir=path/to/directory/containing/notebooks
If you're already in the directory containing your notebook, you can omit the --notebook-dir
flag.
Once your server is running, you can open, run, and edit your notebooks by going to your browser and
entering 127.0.0.1:8888
as the URL. 127.0.0.1
tells your browser to connect to your computer rather
than to a remote server, and :8888
tells it to connect to port 8888, which is the default port on which
ipython notebook
runs. You can change the port for the server by passing --port=<number>
.
Creating an Isolated Python Environment
I highly recommend using virtualenv
for maintaining isolated python installs for particular projects. I also use
the excellent virtualenvwrapper
library, which provides a nicer interface for displaying and switching between
virtualenvs. You can get both of these modules by running:
pip install virtualenv virtualenvwrapper
Assuming you have both virtualenv
and virtualenvwrapper
installed, you can
create an isolated environment for these notebooks by running
mkvirtualenv <env_name>
(where you can replace <env_name>
with the name you actually want to use).
You can then switch between environments using the workon
command
Example
workon notebook_env
\# Do notebook stuff.
...
workon some_other_project_env
\# Do other project stuff.
Installing Dependencies
- If you haven't already done so, create a virtual environment so we have a clean slate and don't interfere with any other projects.
- Install
IPython
with all optional dependencies by runningpip install ipython[all]
- Install
zipline
by runningpip install zipline
. This will also installzipline
's dependencies, including-
numpy
-
scipy
-
pandas
-
- Install
matplotlib
by runningpip install matplotlib
. If this is your first time installingmatplotlib
, you may get errors complaining that you're missing certain C libraries. If you're onOSX
I recommend Homebrew for installing these dependencies. It provides an interface similar to package managers likeapt-get
oryum
that you might use on a Linux distribution.