I am using IPython notebook and I want to edit programs in an external editor.
How do I get the %edit file_name.py
to open an editor such as Notepad++.
3.1. To launch Jupyter Notebook App: Click on spotlight, type terminal to open a terminal window. Enter the startup folder by typing cd /some_folder_name . Type jupyter notebook to launch the Jupyter Notebook App The notebook interface will appear in a new browser window or tab.
A Jupyter notebook is neither a simple text editor nor a full-featured IDE. Jupyter notebooks provide a quick and streamlined way for problem-solvers to prototype code and quickly share code.
Running %edit?
will give you the help for the %edit
magic function.
You need to set c.TerminalInteractiveShell.editor
, which is in your ipython_config.py. I'm not quite sure where this is located in Windows; on OS X and Linux, it is in ~/.ipython. You'll want to set the variable to be the full path of the editor you want.
Alternatively, you can create an environment variable EDITOR in Windows itself, and set that equal to the full path of the editor you want. iPython should use that.
I'm using Windows 7 and 8 (and 10TP) and Python 3.4.2.
I started with ipython locate
to tell me where ipython thought config files suggested elsewhere should be. When I saw it was different I read around and came up with the following:
ipython locate
gave me c:\users\osmith\.ipython
, not the _ipython
you'll see mentioned in the YouTube videos done with Windows XP,ipython locate
specifies for a profile directory; if you aren't actively doing anything with ipython profiles, it should be .ipython\profile_default
, if you are using profiles, then I leave it to you to s/profile_default/${YOUR_PROFILE_NAME}/g
ipython_config.py
file, if it's not there, tell IPython to initialize itself: ipython profile create
If you are the kind of person who hasn't messed around with their console overly much and installs things in standard places, you can skip straight to this step by typing: ipython profile create
followed by start notepad .ipython\profile_default\ipython_config.py
.
c.TerminalInteractiveShell.editor
,Replace the text between the apostrophes ('notepad'
) with the path of our desired editor, e.g.
c.TerminalInteractiveShell.editor = 'c:/program files (x86)/noddyeditor/noddy.exe'
There is a catch here, though; some modern editors get a bit fancy and automatically and, when invoked like this, detach from the console. Notepad++ and Sublime Text, for example. Sublime accepts a "--wait" option, which works some of the time; this tells the command invocation to hang around until you close the file, for some definition of until
and some other definition of close
.
However, the following setting will work most of the time for sublime text:
c.TerminalInteractiveShell.editor = '"c:/program files/sublime text 3/subl.exe" --wait'
(assuming c:\program files\ is where your sublime text 3 directory is)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With