What is the way to set ipython notebook server parameters when running notebook with django-extensions?
Asked Answered
T

2

9

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.

Tilt answered 14/4, 2015 at 15:54 Comment(0)
W
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

Wallack answered 30/4, 2015 at 11:10 Comment(1)
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.Tilt
C
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',
]
Critique answered 23/5, 2016 at 19:54 Comment(1)
This must be the accepted answer. This works like charmBerey
W
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

Wallack answered 30/4, 2015 at 11:10 Comment(1)
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.Tilt

© 2022 - 2024 — McMap. All rights reserved.