Before you keep reading...
Runestone Academy can only continue if we get support from individuals like you. As a student you are well aware of the high cost of textbooks. Our mission is to provide great books to you for free, but we ask that you consider a $10 donation, more if you can or less if $10 is a burden.
Before you keep reading...
Making great stuff takes time and $$. If you appreciate the book you are reading now and want to keep quality materials free for other students please consider a donation to Runestone Academy. We ask that you consider a $10 donation, but if you can give more thats great, if $10 is too much for your budget we would be happy with whatever you can afford as a show of support.
15.1. Installing Juypter Notebooks through Anaconda¶
If you don’t already have Jupyter, it is a Python distribution that contains everything you need for the companion code for this book. It is easy to install on Windows, Mac, and Linux, and because it does a user-level install, it will not interfere with other Python installations.
Information about installing Anaconda is here: https://www.anaconda.com/products/individual
The code for this book works in Python 3.
When you install Anaconda, you should get Jupyter by default, but if not, run
conda install jupyter
Once you have Jupyter, you can get Allen Downey’s code from this Git repository on Github. If you have a Git client installed, you should be able to download it by running:
git clone https://github.com/AllenDowney/ThinkComplexity2.git
It should create a directory named ThinkComplexity2. Otherwise you can download the repository in this zip file and unzip it.
Then cd into the new directory:
To make sure you have the packages you need, you can use environment.yml to create a Conda environment named complexity.
conda env create -f environment.yml
Then activate the new environment
conda activate complexity
To start Jupyter, run:
cd code jupyter notebook
Jupyter should launch your default browser or open a tab in an existing browser window. If not, the Jupyter server should print a URL you can use. For example, you will likely get something like:
~/ThinkComplexity2$ jupyter notebook [I 10:03:20.115 NotebookApp] Serving notebooks from local directory: /home/downey/ThinkComplexity2 [I 10:03:20.115 NotebookApp] 0 active kernels [I 10:03:20.115 NotebookApp] The Jupyter Notebook is running at: http://localhost:8888/ [I 10:03:20.115 NotebookApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation).
In this case, the URL is http://localhost:8888. When you start your server, you might get a different URL. Whatever it is, if you paste it into a browser, you should should see a home page with a list of the notebooks in the repository.
Click on chap09.ipynb. It should open the notebook for Chapter 9.
Select the cell with the import statements and press “Shift-Enter” to run the code in the cell. If it works and you get no error messages, you are all set.
If you get error messages about missing packages, you can install the packages you need using your package manager, or install Anaconda.
If you have trouble with the animations, you might have to install ffmpeg. The animations are not necessary for the text.