[IPython-dev] [Anaconda Support] Re: What's the easiest way to open an IPython Notebook server in a particular directory on Windows?

Matt Merrifield rmatthewmerrifield@gmail....
Mon Feb 24 15:55:53 CST 2014


Clever! Very simple and useful. I like it!

Personally, I set up .ipynb files to be opened by nbconvert when clicked
(done with another registry key). So when I double-click on any .ipynb
file, it generates a fresh .html render that I can e-mail to the rest of my
team, even the ones who don't use IPython.

The contents of the key to associate nbconvert with .ipynb :

Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\.ipynb\shell\nbconvert\command]
@="C:\\Windows\\system32\\cmd.exe /K ipython nbconvert \"%1\""


This one took some trial-and-error to get right -- windows shell scripting
is not my strong suit -- so somebody may have a better way to do this.
Regardless, I've found the nbconvert functionality to be really useful.

Perhaps the anaconda team could add a few things to the .ipynb
file-extension context menu? Ideally the default behavior would be
something like Ian's solution, to open the notebook. Ideally, it would open
in the current kernel (to avoid the multitude of command prompt windows). A
secondary option available through a right-click to run nbconvert on the
notebook would be really useful too.


On Mon, Feb 24, 2014 at 1:02 PM, Ian Bell <ian.h.bell@gmail.com> wrote:

> Another even simpler possibility, one I use myself, is to make a batch
> file called ipython_nb.bat (or whatever you want), with contents "ipython
> notebook %1" (without the quotes).  Then right click a .ipynb file and set
> the ipython_nb.bat file as the default file opener for ipynb files.  Works
> a treat.  You could add other command line parameter as well.  Only mildly
> negative thing is that you can get quite a few command prompts scattered
> around from all the servers if you use this method regularly.
>
> Ian
>
>
>
>
> On Mon, Feb 24, 2014 at 9:51 PM, Aron Ahmadia <aron@ahmadia.net> wrote:
>
>> Awesome!  Both of those are comprehensive solutions to the "not able to
>> launch IPython in the right folder" problems.  I think the first solution
>> is actually a good candidate for inclusion in the Software Carpentry
>> "Configuration Problems and Solutions" wiki page being maintained by Justin
>> Kitzes over here:
>> https://github.com/swcarpentry/bc/wiki/Configuration-Problems-and-Solutions
>>
>> Feel free to add your solution, and perhaps a link back to this
>> discussion for how to set up registry keys.  I'd even propose that the
>> Anaconda developers add a context menu option for launching IPython
>> Notebooks in Windows based on your advice.
>>
>> Cheers,
>> Aron
>>
>>
>> On Mon, Feb 24, 2014 at 3:04 PM, Matt Merrifield <
>> rmatthewmerrifield@gmail.com> wrote:
>>
>>> I had this exact problem. I found two solutions that I liked:
>>>
>>> Batch Files
>>> -----------
>>>
>>> Use batch file scripts! A batch file is, after all, just a terminal
>>> command that you run by double clicking it. My co-workers liked this
>>> method a lot better than opening a new command prompt, navigating to where
>>> they wanted to work, and then running the ipython notebook command.
>>>
>>> To make a batch file script that opens an ipython notebook in whatever
>>> directory it's run from:
>>>
>>> 1. Create a simple .txt file: Right Click -> New ->  Text Document
>>> 2. Re-name it "Start IPython Notebook Here.bat" (don't forget to change
>>> the extension!)
>>> 3. Open it with notepad: Right Click on it -> Edit
>>> 4. Add the text "ipython notebook" to the file -- it should look just
>>> like you would type it in a command prompt.
>>> 5. Save & close.
>>>
>>> Now when you double click on the .bat file, a notebook server will spawn
>>> in that directory. You can move the .bat file to wherever you want your
>>> IPython notebook's working directory to be. You can make copies of the .bat
>>> file, and stash one in all the directories you frequently use. You can give
>>> a copy of the file to people that you're training, and they can just
>>> double-click and go. No need to teach them the command prompt.
>>>
>>>
>>> Registry Keys
>>> -------------
>>>
>>> I work with the IPython notebooks daily in different directories all
>>> over my filesystem, so I got tired of copying the .bat script to every
>>> directory I worked in. I added an option to start a notebook in a directory
>>> to my right-click context menu by adding a few registry keys.
>>>
>>> This option is good for anyone who uses IPython frequently, doesn't mind
>>> an extra option in their right-click menu, and is comfortable editing their
>>> windows registry.
>>>
>>> You should be able to create a text document, copy in the text above,
>>> change the extension to .reg, and then run it(just once) to add the context
>>> menu entry. Put the following 5 lines in the file:
>>>
>>>
>>> Windows Registry Editor Version 5.00
>>>
>>> [HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Directory\Background\shell\ipynb]
>>> @="Open IPython Notebook"
>>>
>>>
>>> [HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Directory\Background\shell\ipynb\command]
>>> @="C:\\Windows\\system32\\WindowsPowerShell\\v1.0\\powershell.exe
>>> ipython notebook"
>>>
>>>
>>> Once the registry key has been added, whenever you right-click in a
>>> folder (or on your desktop) you'll have the option to "Open IPython
>>> Notebook". Selecting that option will spawn a powershell instance, and call
>>> "ipython notebook" as if you'd typed it on the command line -- just like
>>> the batch file method, but without the extra file in the directory.
>>>
>>> Note: if you ever want to remove the registry keys, you'll have to open
>>> up regedit.exe and delete them manually. Some users might become frustrated
>>> with the extra option if they rarely use the notebook, and they might have
>>> trouble getting rid of it, so I wouldn't offer this option unless you know
>>> they will use it all the time.
>>>
>>> Another Note: Neither of these methods starts the notebook with the
>>> "--pylab inline" flag. You can get similar functionality with the "%pylab"
>>> or "%matplotlib inline" magics.
>>>
>>> Let me know if you have any questions. I'll do what I can to answer.
>>>
>>> -Matt
>>>
>>>
>>> On Sun, Feb 23, 2014 at 3:09 PM, Jason Moore <moorepants@gmail.com>wrote:
>>>
>>>> Thanks, I already have asked the Anaconda mailing list too. Just
>>>> haven't gotten a response yet.
>>>>
>>>> Maybe I should just include the Windows shortcut in the directory full
>>>> of notebooks. That would work.
>>>>
>>>>
>>>> Jason
>>>> moorepants.info
>>>> +01 530-601-9791
>>>>
>>>>
>>>> On Sun, Feb 23, 2014 at 6:06 PM, Aron Ahmadia <aron@ahmadia.net> wrote:
>>>>
>>>>> It might be better to direct this question to the Anaconda mailing
>>>>> list (cc'd).
>>>>>
>>>>> You could distribute a shortcut for them that does the right thing
>>>>> when you're packaging your repository.  If you come up with something
>>>>> better or that works for you, please add it to the Software Carpentry
>>>>> "configuration problems" Wiki
>>>>> https://github.com/swcarpentry/bc/wiki/Configuration-Problems-and-Solutions
>>>>>
>>>>> Right now Software Carpentry instructors usually get around this by
>>>>> teaching the command line *before* Git :)
>>>>>
>>>>> A
>>>>>
>>>>>
>>>>>  On Sun, Feb 23, 2014 at 6:00 PM, Jason Moore <moorepants@gmail.com>wrote:
>>>>>
>>>>>>  The IPython Notebook shortcut installed by Anaconda defaults to
>>>>>> opening in the "IPython Notebooks" directory. Is there an easier (point and
>>>>>> click?) method to opening the server in another directory besides (1) open
>>>>>> a CMD prompt and cd'ing to the directory or (2) changing the "start in"
>>>>>> properties of the shortcut?
>>>>>>
>>>>>> I'm giving a tutorial to command line novices and was hoping for
>>>>>> something very simple for them to open up the notebook server in the
>>>>>> correct directory.
>>>>>>
>>>>>> Jason
>>>>>> moorepants.info
>>>>>> +01 530-601-9791
>>>>>>
>>>>>> _______________________________________________
>>>>>> IPython-dev mailing list
>>>>>> IPython-dev@scipy.org
>>>>>> http://mail.scipy.org/mailman/listinfo/ipython-dev
>>>>>>
>>>>>>
>>>>>
>>>>> _______________________________________________
>>>>> IPython-dev mailing list
>>>>> IPython-dev@scipy.org
>>>>> http://mail.scipy.org/mailman/listinfo/ipython-dev
>>>>>
>>>>>
>>>>
>>>> _______________________________________________
>>>> IPython-dev mailing list
>>>> IPython-dev@scipy.org
>>>> http://mail.scipy.org/mailman/listinfo/ipython-dev
>>>>
>>>  --
>>> Anaconda Community Support Group Brought to you by Continuum Analytics
>>> ---
>>> You received this message because you are subscribed to the Google
>>> Groups "Anaconda - Public" group.
>>> To unsubscribe from this group and stop receiving emails from it, send
>>> an email to anaconda+unsubscribe@continuum.io.
>>> To post to this group, send email to anaconda@continuum.io.
>>> Visit this group at
>>> http://groups.google.com/a/continuum.io/group/anaconda/.
>>>
>>
>>
>> _______________________________________________
>> IPython-dev mailing list
>> IPython-dev@scipy.org
>> http://mail.scipy.org/mailman/listinfo/ipython-dev
>>
>>
>
> _______________________________________________
> IPython-dev mailing list
> IPython-dev@scipy.org
> http://mail.scipy.org/mailman/listinfo/ipython-dev
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.scipy.org/pipermail/ipython-dev/attachments/20140224/55997b5b/attachment.html 


More information about the IPython-dev mailing list