Question

I'm a ST2 user (mainly on Python) and I use IPython notebook as well. Before, it was all fine, I could run IPython notebook from ST2 command (ST2 then opened a new tab and there are interactive cells etc.)

Since yesterday I upgraded ipython to version 2.0 using pip. From then on I cannot have the notebook tab in ST2 anymore. Trying to input the command 'open ipython notebook' to ST commandline returns nothing:

>>> "open ipython notebook"
'open ipython notebook'

Is this the problem of compatibility? Maybe the plug in of ST2 does not work with version of ipython anymore? I notice that in version 2.0, the link to the home page of the ipython server changed a bit. Can you suggest how to manually edit the configuration of ST2 ipythonnotebook plugin to make it run again?

>>> open ipython notebook
  File "<string>", line 1
    open ipython notebook
               ^
SyntaxError: invalid syntax
Was it helpful?

Solution

There are a couple of issues. First, IPython 2.0 doesn't work with the IPython Notebook plugin. This was reported 3 months ago, and the developer hasn't done anything about it yet.

Second, even if you hadn't upgraded IPython, you're entering open ipython notebook in the wrong location. You should be typing that into the Command Palette (CtrlShiftP on Windows/Linux, P on OS X), not the Sublime console (Ctrl`).

So, there are two options. The first is to downgrade your version of IPython back to the one you were using before, and everything will work again. The downside of this is you won't have access to the latest features of IPython, which may or may not be an issue depending on your workflow.

The second option is to run IPython via the SublimeREPL plugin. One nice thing about this is the ability to see images as you generate them, as they pop up in new windows. Downsides include the current lack of ability to connect to running notebook servers, the fact that you can't save your work as an .ipynb file, and the different way of presenting data - it's more line-based, not cell-based, so for example if I define a loop:

In [1]: for i in range(10):
   ...:     print(i)

and want to modify and rerun it later, using the arrow keys to go back through the history only goes line-by-line, not cell-by-cell. That means you'd have to rewrite your loop each time you want to run it. I mainly use SublimeREPL/IPython to test snippets of code as I'm writing to make sure they do what I want them to.

OTHER TIPS

Instead of running a notebook, you can directly call ipython using following configuration at the keymap bindings (Preferences > Key Bindings - User):

[{ "keys": ["f9"], "command": "repl_open",
                 "caption": "Python - IPython",
                 "id": "repl_python_ipython",
                 "mnemonic": "p",
                 "args": {
                    "type": "subprocess",
                    "encoding": "utf8",
                    "autocomplete_server": true,
                    "cmd": {
                        "osx": ["python", "-u", "${packages}/SublimeREPL/config/Python/ipy_repl.py"],
                        "linux": ["python", "-u", "${packages}/SublimeREPL/config/Python/ipy_repl.py"],
                        "windows": ["python", "-u", "${packages}/SublimeREPL/config/Python/ipy_repl.py"]
                    },
                    "cwd": "$file_path",
                    "syntax": "Packages/Python/Python.tmLanguage",
                    "external_id": "python",
                    "extend_env": {
                        "PYTHONIOENCODING": "utf-8",
                        "SUBLIMEREPL_EDITOR": "$editor"
                    }
                }

                }
]

So, By clicking F9, it will open ipython on new shell

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top