Anaconda and Jupyter Notebook

30 Mar 2018
[ Python  Programming  Jupyter  ]

This is a guide for installing Ananconda and Jupyter Notebook

Install and Configure Anaconda

Install Anaconda

  • Anaconda can be downloaded from Anaconda’s website. It has both Linux and Windows versions
  • install Anaconda
    bash *.sh
    
  • After installation, set the default python3 version by adding the following code to “.bashrc”. Then restart the connection. The default “.bashrc” will be changed for Anaconda
    # added by Anaconda3 4.0.0 installer
    export PATH="/home/ubuntu/anaconda3/bin:$PATH"
    
    
  • install modules
    conda list # check installed modules
    conda install netCDF4
    
  • update
    conda update anaconda

  • create an environment
    conda create -n py35 python=3.5 anaconda

  • activate and use the created environment
    source activate py35

  • deactivate an environment
    source deactivate py35

Jupyter Notebook

start Jupyter Notebook

# general start 
jupyter notebook

# in background
jupyter notebook &> /dev/null &

# check opened notebook
jupyter notebook list

# close jupyter notebook
kill $(pgrep jupyter)

add extensions to Jupyter Notebook

Jupyter nbextensions

# install the nbextensions
pip install jupyter_contrib_nbextensions
# install js
jupyter contrib nbextension install --user
# enable nbextensions
jupyter nbextension enable codefolding/main

nbconvert for converting “ipython” to “pdf”

sudo apt-get install pandoc
git clone https://github.com/jupyter/nbconvert.git
cd nbconvert
pip install -e .
# test nbconvert
pip install nbconvert[test]
py.test --pyargs nbconvert