Tips for ipython notebook

2015年08月26日

run ipython notebook as a service

Put this script to /etc/init/ and use sudo start ipython to start it.

# ipython notebook startup Script
description "ipython notebook"
 
start on runlevel [2345]
stop on runlevel [016]
respawn limit 10 5

script
    exec sudo -u username ipython notebook --pylab=inline --pprint
end script

You should also change the default initial path of ipython notebook by uncommenting and changing the following lines of your profile config file( default ~/.config/ipython/profile_default/ipython_notebook_config.py)

c = get_config()
c.NotebookApp.open_browser = False
c.NotebookApp.ipython_dir = u'~/.config/ipython/notebook'
c.NotebookApp.notebook_dir = u'~/.config/ipython/notebook'
c.NotebookManager.ipython_dir = u'~/.config/ipython/notebook'
c.NotebookManager.notebook_dir = u'~/.config/ipython/notebook'
c.FileNotebookManager.ipython_dir = u'~/.config/ipython/notebook'
c.FileNotebookManager.notebook_dir = u'~/.config/ipython/notebook'

custom web page fonts and so on

Put this css file into your profile path( default $HOME/.config/ipython/profile_default/static/custom/custom.css).

use pyenv to handle multiple version of python

Put the hook script whence.bash to /path/to/pyenv.d//which/whence.bash to guess the python version from the program name.

if [ -n "$PYENV_COMMAND" ] && [ ! -x "$PYENV_COMMAND_PATH" ]; then
  versions=($(pyenv-whence "${PYENV_COMMAND}" 2>/dev/null || true))
  if [ -n "${versions}" ]; then
    if [ "${#versions[@]}" -gt 1 ]; then
      echo "pyenv-implicit: found multiple ${PYENV_COMMAND} in pyenv. Use version ${versions[0]}." 1>&2
    fi
    PYENV_COMMAND_PATH="${PYENV_ROOT}/versions/${versions[0]}/bin/${PYENV_COMMAND}"
  fi
fi