what is the ipython notebook “Terminals” menu opti

2019-02-02 23:49发布

问题:

I am running ipython notebook on my OSX machine and/or my ubuntu 14.04 machine. I am using ipython 3.0.0, and ipython (jupyter) notebooks.

When I start an ipython notebook, under New there is a terminal option, but it's unavailable for me. I haven't been able to find any documentation on this feature, how to activate it or what it does. The ipython notebook --help command doesn't mention it and I haven't found anything in the documentation either. I haven't discovered the special keywords to search google for to get any information either.

What does this feature do? How do I activate it? Is there any documentation on this available?

回答1:

Here's the code in Lib/site-packages/IPython/html/notebookapp.py responsible for this item (located the file by searching the source for "Terminals" case-sensitively):

def init_terminals(self):
    try:
        from .terminal import initialize
        initialize(self.web_app)
        self.web_app.settings['terminals_available'] = True
    except ImportError as e:
        log = self.log.debug if sys.platform == 'win32' else self.log.warn
        log("Terminals not available (error was %s)", e)

As you can see, there should be a message in the console log specifying what went wrong (you may need to increase log verbosity with ipython notebook --log-level=<level> to see it). In my case, it said:

Terminals not available (error was No module named fcntl)

The html.terminal module that is being imported appears to provide a web-based IPython interactive console.



回答2:

IPython/Jupyter appears to support browser-based interactive terminal sessions. This is enabled on my machine by installing the terminado package with pip or conda. This fixes the "Terminals Unavailable" message on the drop-down, and lets me start up a (bash) terminal session in a new tab.

See this commit: IPython on GitHub



回答3:

Support for Windows terminals with terminado dependency was added in Jupyter 5.3.0:

https://github.com/jupyter/notebook/pull/3087



回答4:

Actually it's jupyter notebook 5.3.0, not jupyter. the two versions is not the same thing. - jupyter --version - jupyter notebook --version

I ever suffered from this.