how to open Jupyter notebook in chrome on windows - windows

On my Windows PC, i have anaconda installed and when I open a jupyter notebook, it opens up in internet explorer, but I would like to use Chrome instead. Does anyone know how to achieve this?

If you haven't already, create a notebook config file by running
jupyter notebook --generate-config
Then, edit the file jupyter_notebook_config.py found in the .jupyter folder of your home directory.
You need to change the line # c.NotebookApp.browser = '' to c.NotebookApp.browser = 'C:/path/to/your/chrome.exe %s'
On windows 10, Chrome should be located C:/Program Files (x86)/Google/Chrome/Application/chrome.exe but check on your system to be sure.

Just make chrome as a default browser and launch the jupyter . It will work
To Make Google chrome a default browser , follow steps
Click on Customize and Control Google chrome (The vertical three dots on the Upper right corner of your google chrome browser)
Click on Settings and scroll down to Default browser.
Change the value of the default browser to Google Chrome by clicking on whatever your default browser is there and selecting Google Chrome.
Note: In windows 10, you will be redirected to Default apps under your computer's Settings. Please scroll down to Web browser and Select Google Chrome. If promted, Click on OK else just close the settings tab and return to your command or anaconda prompt and type jupyter notebook as usual. A new jupyter notebook tab should open in Google Chrome now.

For those who still have trouble launching Chrome automatically from cmd, try replacing
# c.NotebookApp.browser =''
in the file jupyter_notebook_config.py with
import webbrowser
webbrowser.register('chrome', None, webbrowser.GenericBrowser('C:\Program Files (x86)\Google\Chrome\Application\chrome.exe'))
c.NotebookApp.browser = 'chrome'
or the appropriate location, there shouldn't be need to install anything via pip.
Ref: https://support.anaconda.com/customer/en/portal/articles/2925919-change-default-browser-in-jupyter-notebook

Create and edit the jupyter notebook config file with the following steps:
Launch Anaconda Prompt
Type jupyter notebook --generate-config
Type notepad path_to_file/jupyter_notebook_config.py to open it (change path_to_file)
Modify #c.NotebookApp.browser = '' to c.NotebookApp.browser = 'C:/Program Files (x86)/Google/Chrome/Application/chrome.exe %s'
Save the file and close it
Jupyter notebook will now use Chrome.
EDIT
In Windows 10 I had to type
notepad .jupyter/jupyter_notebook_config.py
And substitute the line with
c.NotebookApp.browser = 'C:/Program Files/Google/Chrome/Application/chrome.exe %s'

step1: Go to search menu of windows and type default app.
step 2: go to WEB BROWSER title and change it to Google Chrome.
step3: Go to search menu of windows and type jupyter notebook
This will open the jupyter notebook in Google Chrome

Run the jupyter notebook --generate-config command on the anaconda prompt.
Then edit the jupyter_notebook_config.py file.
Find the c.NotebookApp.Browser like this:
c.NotebookApp.browser = 'c:/Program Files (x86)/Google/Chrome/Application/chrome.exe %s'
Works on mine.

Take any html file on your computer and set the default browser to open html files to chrome. This will automatically open jupyter notebook with chrome. Worked for me.

For windows set the default browser to open html files to Chrome. Configuration > Default Apps > Default Apps by File Type. Worked for me.

I found an easier solution that may help beginners to coding.
go to
C:\Users\'-your user-'\AppData\Roaming\jupyter\runtime
and find a file named
nbserver-6176-open.html
then
Right-click > open with > Choose default program...
Here, what ever you choose would be saved on your Windows to open all HTML files; therefore when you run Jupyter notebook, it would open in the program you want.

You don't have to change anything in the jupyter config code, you just have to make Chrome as your default browser in the setting. Jupyter opens whichever is the default.

For some reason Louise's answer didn't work for me I had to:
-Open anaconda prompt and generate the config file for Jupyter: jupyter notebook --generate-config
-Open the newly created config file at: C:\Users\builder\.juptyer\jupyter_notebook_config.py
-Add the following to the file:
import webbrowser
webbrowser.register('chrome', None, webbrowser.GenericBrowser(r'C:\Program Files (x86)\Google\Chrome\Application\chrome.exe'))
c.NotebookApp.browser = 'chrome'

I just followed 2 steps and everythings working as expected
step-1
set chrome executable path environment varibale, in my case it is(you can test it in cmd by typing chrome and enter, it will open your chrome browser if path set properly):-
C:\Program Files\Google\Chrome\Application\chrome.exe
step-2 just run below command and you are good to go
jupyter notebook --browser chrome

See response on this thread that has worked for me:
https://stackoverflow.com/a/62275293/11141700
NOTE - Additional STEP 3 that has made the difference for me compared to similar approaches suggested here
In short:
Step 1 - Generate config for Jupyter Notebook:
jupyter notebook --generate-config
Step 2 - Edit the config file using "nano" or other editor
The config fileshould be under your home directory under ".jupyter" folder:
~/.jupyter/jupyter_notebook_config.py
Step 3 - Disable launching browser by redirecting file
First comment out the line, then change True to False:
c.NotebookApp.use_redirect_file = False
Step 4 - add a line to your .bashrc file to set the BROWSER path
export BROWSER='/mnt/c/Program Files (x86)/Google/Chrome/Application/chrome.exe'
For me it was Chrome under my Windows Program File. Otherwise any linux installation under WSL doesn't have a native browser to launch, so need to set it to the Windows executable.
Step 5 - restart .bashrc
source .bashrc

In the windows when we open jupyter notebook in command prompt we can see the instructions in first 10 lines in that there is one instruction- "to open notebook, open this file in browser file://C:/Users/{username}/appdata/roaming/jupyetr/runtime/nbserver-xywz-open.html " , open this html with browser of your choice.

If you tried all these "solutions" and still doesn't work, try to open the url over HTTP (not HTTPS <-- the real problem with chrome) and using an Incognito window (press Ctrl + Shift + N on Chrome)
This worked for me. Hope it helps

I just set chrome as my default browser and jupyter launches in Chrome now.
However, we have also the following approach, but it did not work for me:
"CONDA version 4.7.5 and jupyter 6.0.0. - Windows 10"
1) Open Anaconda and launch your environment in terminal
2) Create config file and open file in notepad
3) Modify line of NotebookApp with chrome and save modification
4) Launch Jupyter
:( ... but it still launches in Mozilla.

Related

Jupyter Notebook Cannot Access Desktop Files and Folders

I recently bought a new M1 Pro Macbook with macOS Monterey. Migrated all my stuff from my previous Macbook Air over to it.
I opened my Jupyter Notebook via Anaconda but now, it cannot detect my Desktop files and folders (the Desktop folders are on the extreme right of the screenshot):
I have also went to System Preferences -> Security & Privacy -> Privacy -> Files and Folders to check on the access and permissions, but nothing seems amiss:
Attaching the Jupyter terminal boot-up here as well just for reference:
Can anyone assist? Thank you!
Jupyter can't cd outside of your Users/user path. However, you can change that folder in the jupyter_notebook_config.py. Look for the c.NotebookApp.notebook_dir entry to point to the desired working directory. You can create this config file from your shell via
jupyter notebook --generate-config
Small configuration is required to view these files on jupyter notebook.
Get the path of jupyter_notebook_config.py file.
Below mentioned command can be used to find it -
jupyter notebook --generate-config
open the file and search for c.NotebookApp.notebook_dir
this might be configured to default value i.e. ''
Reconfigure it and update path of directory contain code files,
like -
c.NotebookApp.notebook_dir = /Volumes/Technical/Python

How to change the windows drive for JupyterLab in Anaconda Navigator?

Under Windows, JupyterLab does not allow navigation in the UI to any drive other than the drive that JupyterLab was started in. By default this is the C: drive.
How can you access notebooks on another drive?
Anaconda does not allow switching between drives but you can start Jupyter Lab or a Jupyter notebook on another drive, for example the D: drive.
First shutdown any running JupyterLab, then
Open a terminal window from within Anaconda Navigator. To do this, select environments in the Navigator window and then click the green "play" arrow next to base(root) -- or which ever environment you are using.
then in the terminal window type
jupyter notebook --generate-config
this will generate a file in your user directory under .jupyter\jupyter_notebook_config.py
edit the file.
Set the variable c.NotebookApp.notebook_dir to whatever directory you want to start in, for example
c.NotebookApp.notebook_dir = "D:\mydir"
NOTE do not put a trailing backslash. Also if the directory pathname contains spaces ensure you are using double quotes.
save the file and test that all is working. In the command line type
jupyter lab
this should start JupyterLab correctly, check for any errors in the terminal window. JupyterLab should start in the directory you set in the file.
If all is well, shutdown JupyterLab and run it from the Anaconda Navigator window as usual. All should work now.
As mentioned by GreyMS in this github issue, you can use an mklink:
mklink /D D_Drive D:\sources

Launching jupyter notebook from terminal starts signal desktop messenger as well

when I am launching a jupyter notebook from the terminal on my ubuntu 18.04, the signal desktop messenger app launches as well. Does anyone encountered this issue and knows how to solve it? Thanks
I have the same issue here (Ubuntu 18.04) and I discovered that the default application to run *.html-Files was also changed to Signal Desktop App. After changing the default application for *.html backwards to Firefox jupyter notebook launches already in the browser.
I've found a way to do this that is (possibly) more directly related to Jupyter. You can create a Jupyter config file and change the browser preference to whatever you like. Type:
jupyter notebook --generate-config
on the command line. It will tell you where the config file was created (probably $HOME/.jupyter/jupyter_notebook_config.py). Open the config file and look for the following line:
#c.NotebookApp.browser = ''
you can uncomment it and change it to include your desired web browser. For example this is how I changed it to firefox:
c.NotebookApp.browser = '/usr/lib/firefox/firefox'
Save the file, exit and try again.
This worked for me on Ubuntu 16.04.6 (LTS) and I had a similar problem but this answer didn't work for me. The situation I found myself in was that jupyter launched Firefox correctly in a normal environment but it launched the wrong application when I was in a directory that used a different python version which was being controlled via pyenv. I was launching the notebook like this: pipenv run jupyter lab. For completeness it was launching Signal for me too and - no - I don't really understand why. I found help in the thread connected to this issue on the jupyter/notebook Github page.

Anaconda Jupyter Notebook starting in different directories when run from cmd and Start Menu

I was trying to change the default starting directory of Anaconda Jupyter notebook on Windows 10
Conda version 4.3.31
Jupyter notebook version 5.2.2
From this link, I learned that I need to change c.NotebookApp.notebook_dir attribute to change the default directory.
I executed jupyter --config-dir to find the location of the configuration file and executed jupyter notebook --generate-config to generate the configuration file and changed c.NotebookApp.notebook_dir value to the directory I want.
Now if I run jupyter notebook command in cmd, it will start in the directory I mentioned. But if I run from the start menu, it is starting in the default folder.
Does anyone know why this is happening? I tried to change the path in the Start in field in shortcut properties of Jupyter Notebook. After doing that, I am not able to open from the start menu. When I click the Icon, it just opens and closes immediately.
I have (had) the same problem.
My workaround:
Anaconda (version 2018.12) installed in
C:\Anaconda3
When running from Start Menu right click on Jupyter Notebook. In my case there follow two more submenus. The first is More and the second is something like Open folder (I have a German Windows version, so I just can guess the English Menu texts.).
When opening that folder you will see a file (shortcut) with the name Jupyter Notebook. The folder in my case looks like this:
C:\Users\Andreas\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Anaconda3 (64- bit)
Right click this file (shortcut) and edit its properties. There you find the Target of the shortcut, which in my case is (rather longish):
C:\Anaconda3\python.exe C:\Anaconda3\cwp.py C:\Anaconda3 C:\Anaconda3\python.exe C:\Anaconda3\Scripts\jupyter-notebook-script.py "D:\Dropbox\ipython_notebooks"
where I edited the last entry, which is the folder where I store my notebooks.

open ipython notebook with firefox

I'm using Windows 10 and my default browser is Chrome. If I go to the Firefox directory (C:\Program Files (x86)\Mozilla Firefox) and open the command prompt and type:
ipython notebook --browser='firefox'
then the notebook opens as expected. However if I navigate to the folder which contains my files and try to do something like:
ipython notebook --browser='C:\Program/Files/(x86)\Mozilla/Firefox\firefox'
then it does not launch. The error is "No web browser found: could not locate runnable browser". I have tried many variations of this with no success. This was brought up in a similar thread a couple years ago (Launch IPython notebook with selected browser) with no resolution that I could see.

Resources