Skip to content

Instantly share code, notes, and snippets.

@pmlandwehr
Last active May 27, 2017 06:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pmlandwehr/e38a1277753cb1adec5c968191840320 to your computer and use it in GitHub Desktop.
Save pmlandwehr/e38a1277753cb1adec5c968191840320 to your computer and use it in GitHub Desktop.
Install Conda and deploy Jupyter in an Ubuntu, x64 environment
#!/usr/bin/env bash
# Install any necessary packages with apt-get
sudo apt-get install -y curl wget
# Get installer
curl https://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh \
--output miniconda_installer.sh
# Run installer
bash miniconda_installer.sh -b
# Add conda to path, reload
echo 'PATH="/root/miniconda3/bin:$PATH"' >> ~/.bashrc
. .bashrc
# make environment for notebook
# and enter it
conda create -n nbk_env python=3.5 jupyter pandas numpy scipy scikit-learn matplotlib seaborn
source activate nbk_env
# Update conda, add conda-forge
conda config --add channels conda-forge
# Install some packages that might be missing.
conda install -y tqdm
# Generate notebook config
jupyter notebook --generate-config
# set up password:
# 1. Get a password from the command line
nbookpass=$(python -c "from notebook.auth import passwd; print(passwd())")
# 2. set up a certificate
mkdir certs
cd certs
certdir=$(pwd)
openssl req -x509 -nodes -days 365 -newkey rsa:1024 -keyout mycert.key -out mycert.pem
# 3. Save the password and cert to the notebook configuration
cd ~
sed -i "1 a\
c = get_config()\\
c.NotebookApp.certfile = u'$certdir/mycert.pem'\\
c.NotebookApp.ip = '*'\\
c.NotebookApp.open_browser = False\\
c.NotebookApp.password = u'$nbookpass'\\
c.NotebookApp.port = 8888" .jupyter/jupyter_notebook_config.py
# Install some helper packages for the notebook
conda install -y jupyter_nbextensions_configurator nbbrowserpdf nbpresent
pip install jupyter_qtconsole_colorschemes # will be merged with the previous line once in conda-forge
# exit environment
source deactivate
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment