45
votes

I installed Anaconda on my Windows 10 machine.

I have a few Jupyter notebooks on my pc and I would like to associate them with Jupyter, so they can be opened by double-clicking on the file, to avoid having to open Jupyter and navigate to the notebooks folders each time. Is this possible?

All notebooks should open in the same Jupiter Kernel (same localhost in the browser address bar), without starting a new kernel for every file I click.

PS I asked here because I figured this question to be more of interest for programmers, but if you think it would be more suited for SuperUser, I'll flag it for migration.

7
I don't think it would be possible to double-click on an ipynb file and have it start a Jupyter Notebook server and open the file. If it is possible, I think you would have to create a separate batch script that is associated with the ipynb files, and in that batch script, start the Jupyter Notebook. It would probably be easier to open the Anaconda Prompt, cd to the directory with the files, and then start the Jupyter notebook.darthbith
@dartbith that's what I've been doing (opening the Anaconda prompt, cd to the ipnyb dir & execute jupyter notebook). I was looking for alternatives, but apparently there aren't any.DeltaIV
You could create a copy of the shortcut to the Anaconda Prompt and change the "Start in" folder for the copied shortcut. At least then you wouldn't have to do the cd step. Unfortunately, I'm not on Windows at the moment so I can't check that this would work.darthbith
@darthbirth checked on Windows and it works. A bit annoying because I have to create a copy of the shortcut for each Jupyter project folder, but I don't work on more than one notebook project at the same time, so it's ok (I much prefer to use a real IDEs such as PyCharm to develop Python code, Jupyter is mostly for communication/reporting).DeltaIV
** Solution is given by @endolith in an answer below **. Not yet marked as correct, but it is correct.Eureka

7 Answers

60
votes

Install nbopen: https://github.com/takluyver/nbopen

pip install nbopen
python -m nbopen.install_win

Now you can double-click on *.ipynb files:

Example.ipynb icon in Windows 7

19
votes

If you have Jupyter installed with Anaconda you can do the following.

Create a little batch file (e.g. start_jupyter_notebook.bat) with the content (the commands are from the Jupyter shortcut):

@echo off
set ANACONDAPATH=C:\_work\_programs\Anaconda3
%ANACONDAPATH%\python.exe %ANACONDAPATH%\cwp.py %ANACONDAPATH%^
 %ANACONDAPATH%\python.exe %ANACONDAPATH%\Scripts\jupyter-notebook-script.py %1

(of course you will have to change the ANACONDAPATH to your installation)

Then go to one .ipynb file of your choice, right-click on it, go to properties --> open with --> change and select your created batch file.

I am pretty sure this can also be setup for any other Python/Jupyter installation.

P.S. The cwp.py file sets up some environment variables. I guess this is the reason why fredm73's answer did not work for everybody. Apart from that my answer is quite similar in the end.

14
votes

associate .ipnyb with jupyter-notebook.exe

On Windows 10: control panel/Programs/Default Programs/Associate a file type or protocol with a program/Choose default apps by file type

Look at the list of extensions, find '.ipnyb'. Click on icon and locate the jupyter notebook program. In my Anaconda installation, it is found at anaconda/scripts/jupyter-notebook.exe

9
votes

Easiest way for me - double click on the .ipnyb file. When prompted to pick a program to open the extension with go to /ProgramData/Anaconda3/Scripts and locate the jupyter-notebook.exe file and click it.

NOTE - to access the ProgramData folder you will need to view hidden folders in the Windows explorer or access it by typing %programdata% in the navigation line:

enter image description here

1
votes

Just look into your file directory and look for programs that can open the file type and set it as your default app opener but you need to take into consideration that if you want to use Jupiter notebook, you can run jupyternotebook app and locate the file from the jupyter notebook directory.

Secondly, ensure you have added your python.eex to path and run directly from your command prompt. See pictures in the screenshot running a py file in my downloads directory

0
votes

Find the jupter-notebook.exe in the C:\Users\my_username\Anaconda3\Scripts folder. Copy the address. When you're opening the .ipnyb file double click ( if first time) or just do open with and there in the menu you can tick the 'always use this' option and locate the notebook from 'look more programs' option in the menu.

0
votes

For those who installed nbopen in Anaconda but it does not work:

Use Regedit to search for a directory called Jupyter.nbopen, and navigate to its shell\open\command. It should be something like:

HKEY_USERS\****\Software\Classes\Jupyter.nbopen\shell\open\command

Then, change the default to: (Modify the path if you are not installed in default location)

"C:\ProgramData\Anaconda3\pythonw.exe" "C:\ProgramData\Anaconda3\cwp.py" "C:\ProgramData\Anaconda3" "C:\ProgramData\Anaconda3\pythonw.exe" -m nbopen "%1"

The reason behind this is that cwp.py makes sure that the Jupyter is running in Anaconda instead of other Python environments.

Then it should work, although it will activate two invisible pythonw process running in the background.