8

I am using the following command to run an ipython notebook server with django:

./manage.py shell_plus --notebook

The server functions as expected. However, I would like to set the port and not launch a browser when starting the server.

If I were running an IPython notebook server without django I successfully use the following:

ipython notebook --port=9999 --no-browser

I checked the documentation here and tried setting the options using

IPYTHON_ARGUMENTS = [
    '--ext', 'django_extensions.management.notebook_extension',
    '--port=9999',
    '--no-browser,
]

These arguments are loaded after the server has already started and do not change the notebook server settings from what I can gather.

How can I set the notebook server settings when launching the notebook server with django using

    ./manage.py shell_plus --notebook

?

Thank you in advance.

dmmfll
  • 2,666
  • 2
  • 35
  • 41

2 Answers2

25

Running the latest version of IPython (4.2.0), I had to add this to settings.py:

NOTEBOOK_ARGUMENTS = [
    # exposes IP and port
    '--ip=0.0.0.0',
    '--port=8888',
    # disables the browser
    '--no-browser',
]
Diego Ponciano
  • 1,453
  • 1
  • 19
  • 23
5

I had the same problem, and I solved it by creating a new file called ipython_config.py in the same folder as manage.py with the following content:

    c = get_config()

    # Notebook server config below
    # Kernel config
    c.IPKernelApp.pylab = 'inline'  # if you want plotting support always

    # Notebook config: ip address and port
    c.NotebookApp.ip = '0.0.0.0'
    c.NotebookApp.port = 8888

    # disables the browser
    c.NotebookApp.open_browser = False

After this I was able to run the ipython notebook server on the required port and IP address, without launching a browser, simply by running

    python manage.py shell_plus --notebook

You can see more on this config file here: http://ipython.org/ipython-doc/1/interactive/public_server.html

luisf
  • 84
  • 4
  • 3
    I just tried this with IPython version 4.0.0. The ipython_config.py file in my Django project directory was ignored. The server ran with defaults, i.e. `http://localhost:8888/` was the url rather than the one I specified in the ipython_config.py file which IPython 3.2.0 honored. – dmmfll Aug 16 '15 at 12:08