These instructions originally appeared on the “Resources” page of my website, where I link to my Github Gist. As of Dec 21, 2018, I am abandoning the aforementioned gist and will keep this webpage updated as my primary source of information for installing Anaconda1.
Anaconda Basics
Introduction
It is a package manager.
WRITE MORE ABOUT WHAT A PACKAGE MANAGER IS/DOES AND WHY IT SHOULD BE USED
Download
Go download it from https://www.anaconda.com/download/ for your Linux/Windows/OSX
I like to use
wget http://repo.continuum.io/archive/Anaconda3-5.0.1-Linux-x86_64.sh
or if I want to keep things lightweight (may lead to more manual installations later on):
wget https://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh
Install
It will likely be saved in the Downloads folder, so you will install it with something like
bash ~/Downloads/Anaconda3-5.0.1-Linux-x86_64.sh
Use all the defaults, agree to everything, and at the end, hit ENTER to prepend it to your PATH
Environments
Now let’s create an environment for python3:
conda create -n py3 python=3.6 where py3 is just my personal preferred shorthand for python 3. Feel free to use your own.
And one for python2:
conda create -n py2 python=2.7
To remove:
conda remove --name py2 --all
We can now switch between versions of python with commands like
source activate py3 and source activate py2 and then source deactivate when you’re ready to be done.
Diving Deeper
Widgets
Overview:
pip install ipywidgets
jupyter nbextension install --py --user widgetsnbextension
jupyter nbextension enable --py widgetsnbextension
More information about widgets can be found here
Alternatively, in each of these environments, run
conda install -c conda-forge ipywidgets
which will install all sorts of dependencies, including Jupyter notebooks2. It supposedly enables the widgets too but you can run
jupyter nbextension enable --py widgetsnbextension to make sure.
python -m ipykernel install --name py3 --user will then link the kernel to jupyter.
Then --name py3 flag is optional and just assigns a name of your choosing to that kernel.
The version of python used for the kernel is whatever is returned when you ask bash which python (so if you used source activate earlier, it will be the version associated with the kernel whose name is in parentheses in your Terminal session).
The --user flag is necessary.
iPyParallel
https://github.com/ipython/ipyparallel
pip install ipyparallel to install.
ipcluster nbextension enable (add the --user flag as well if you encounter an error).
This one also seems to be necessary to get the clusters to show up:
jupyter serverextension enable --sys-prefix --py ipyparallel
To install for all users (as root):
jupyter nbextension install --sys-prefix --py ipyparallel
jupyter nbextension enable --sys-prefix --py ipyparallel
Kernels
Introduction
TODO: WRITE MORE ABOUT MULTI-KERNEL SUPPORT, provide an example.
Overview
To see all the kernels jupyter is aware of:
jupyter kernelspec list
Management
To remove kernels, use jupyter kernelspec remove
JupyterHub
Introduction
More information here about installation would be helpful, but we’ll be going through this in more detail at another time since JupyterHub will form the basis for the solutions we will use for our classroom environments.
Installation
Configuration
(for personal use)
JupyterLab
Introduction
I love this environment but it is a little tricky to set up properly and get everything working as expected. Though once you do, I doubt you will want to use anything else.
Install
Once Jupyter Lab is installed, go ahead and run it the same way you would a notebook:
jupyter lab (--no-browser)
Widget Extensions
By default (as of Dec 2018), it will be accessible through localhost:8888
Go ahead and launch an instance of Python and see if widgets work.
import ipywidgets as wd
wd.FloatSlider()
If the output of the following is text instead of a widget, try running the following in the command-line (shutdown the server with Ctrl-C twice, then
jupyter labextension install @jupyter-widgets/jupyterlab-manager
And relaunch JupyterLab (if you didn’t close your browswer window, a simple refresh will work to re-establish the connection and pick up where you left off), and try the example above again.
Something that came up once
I saw my server output spitting out TypeError: __init__() got an unexpected keyword argument 'io_loop' over and over again when any kernel was started. Something was going on with the WebSocket I/O communication (whatever that means), but the following downgrade of the Python Web Framework worked to fix it:
pip install tornado==4.5.3
Sharing
Motivation
TODO write about why this is useful
Exporting
conda env export > environment.yml
Which you then load up with
conda env create -f environment.yml
Cloning
You can make an exact copy of an environment by creating a clone of it:
conda create --name myclone --clone myenv
To verify that the copy was made:
conda info --envs