Joe Bergantine | Designer

Running django_extensions' iPython Notebook from a Vagrant Virtual Machine

Forward the port. In the Vagrantfile:

Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
  ...
  config.vm.network "forwarded_port", guest: 8888, host: 8888
  ...

Bring up the virtual machine and shell into it. Install the requirements:

$ pip install django-extensions ipython pyzmq jsonschema terminado jupyter

Add 'django_extensions', to the list of INSTALLED_APPS in the Django project's settings file.

Add a list of configuration options to the Django project's settings file to run the server on 0.0.0.0:8888 and disable the attempt to launch a browser which won't be available in the virtual machine:

NOTEBOOK_ARGUMENTS = [
    '--ip', '0.0.0.0',
    '--port', '8888',
    '--no-browser'
]

Now django-extensions can run it:

$ ./manage.py shell_plus --notebook

And, back on the host, the iPython notebook will be accessible in a Web browser at http://localhost:8888.

Revisions

February 23, 2017
Updated to work with the latest versions of the modules noting the use of the jupyter module to get around the ImportError: No module named notebookapp error when attempting from IPython.html.notebookapp import NotebookApp as well as the replacement of configuration within ipython_config.py with configuration within the project settings file.