-
Notifications
You must be signed in to change notification settings - Fork 5.3k
How can I start a Jupyter server from Python #4873
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Very close!
from notebook.notebookapp import NotebookApp
app = NotebookApp()
app.initialize([])
Square brackets are the command line arguments. Might want to set port and
token, if you actually want to talk to it.
I've never given it a custom io_loop, though... Probably have to overload
.start, as it always use the current one.
More:
https://gist.github.com/bollwyvl/bd56b58ba0a078534272043327c52bd1
…On Tue, Sep 10, 2019, 13:27 Matthew Rocklin ***@***.***> wrote:
I have an existing Python process running a Tornado web application (Dask)
and I would like to run a Jupyter notebook server from within this process,
on the same event loop. I looked around and couldn't find any good
documentation on how to start Jupyter from within Python. Is this easy?
Ideally I would do something like the following:
from notebook import Server
io_loop = tornado.ioloop.IOLoop.current()
server = Server(io_loop=io_loop)await server.start()
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#4873?email_source=notifications&email_token=AAALCRHIHL3ZSSM5VAMXR5DQI7KJTA5CNFSM4IVKQCT2YY3PNVWWK3TUL52HS4DFUVEXG43VMWVGG33NNVSW45C7NFSM4HKQKPZA>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAALCRCWQ7HVOUGTH3PYDWDQI7KJTANCNFSM4IVKQCTQ>
.
|
That works! Nice. OK, so if providing an event loop is hard, I imagine that it's also quite hard to provide my own, already running Tornado HTTPServer. True? It would be interesting to have only one of these running, assuming that Dask and Jupyter don't have any overlapping routes. |
I think one could...
i've usually been interested in taking the already-running, somewhat idiosyncratic notebook tornado loop/server/app to run other things in process so i can muck about with their workings in response to yet other things (usually, kernels, contents, and nb/lab extension-interfacing REST APIs). I must confess, dask has not been one of them, preferring to leave it on the other side of the proxy :P |
It's always better to keep out the riff raff :)
…On Tue, Sep 10, 2019, 5:35 PM Nicholas Bollweg ***@***.***> wrote:
I think one could...
- ... overload NotebookApp.init_webapp
<https://github.com/jupyter/notebook/blob/6.0.1/notebook/notebookapp.py#L1434>
to inject an existing http_server...
- init_webapp could be broken up to not conflate the initialization
of NotebookApp.web_app and NotebookApp.http_server (which pretty
much just owns the port and the SSL)
- but the relationship has been 1:1 to date, as far as i can tell
- ... and teach the originally-launched Application.__call__
<https://github.com/tornadoweb/tornado/blob/v6.0.3/tornado/web.py#L2164>
how to (sometimes) dispatch to this new NotebookApp.__call__ (which
i've never seen overload, but...)
- ... or use the not-exactly-newfangled
<tornadoweb/tornado#1806> callable adapter
<https://github.com/tornadoweb/tornado/blob/v6.0.3/tornado/httpserver.py#L237>
to multiplex
- ... or somehow bolt them all together with inheritance
- do you have a web.Application subclass someplace?
i've usually been interested in taking the already-running, somewhat
idiosyncratic
<https://github.com/jupyter/notebook/blob/6.0.1/notebook/notebookapp.py#L47>
notebook tornado loop/server/app to run other things in process so i can
muck about with their workings in response to yet other things (usually,
kernels, contents, and nb/lab extension-interfacing REST APIs). I must
confess, dask has not been one of them, preferring to leave it on the other
side of the proxy :P
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#4873?email_source=notifications&email_token=AACKZTCZ7UZGCVYBFCN7JVTQJA4M7A5CNFSM4IVKQCT2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD6M4LVI#issuecomment-530171349>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AACKZTGQPSRQFBQPSUZN4MTQJA4M7ANCNFSM4IVKQCTQ>
.
|
how do we do this today in 2025 ? |
found
|
The latest version has made it very easy to launch jupyter notebook from a python module:
|
I have an existing Python process running a Tornado web application (Dask) and I would like to run a Jupyter notebook server from within this process, on the same event loop. I looked around and couldn't find any good documentation on how to start Jupyter from within Python. Is this easy?
Ideally I would do something like the following:
The text was updated successfully, but these errors were encountered: