How to install and use Jupyter Notebook

How to install and use Jupyter Notebook

(1) After ensuring that pip has been installed (the installation process of pip was introduced in the previous article), enter the terminal and execute the following command line to install.

pip install jupyter notebook

The installation process may require installing many bundled packages. If the installation process fails, re-execute the command line installed above to continue the installation.

insert image description here

(2) After the installation is complete, enter "jupyter notebook" in the terminal to open:

jupyter notebook

By default, the original browser of the system will open jupyter notebook:

insert image description here

(3) Sometimes the built-in browser of the system cannot create or run python files after opening jupyter notebook, which may be some compatibility issues. Using Google Chrome can solve this problem. The following settings use Google Chrome to open jupyter notebook by default.

  1. Get the jupyter notebook configuration file jupyter_notebook_config.py, and enter the following command line in the terminal to get the file path:
jupyter notebook --generate-config

As follows:
insert image description here
2. Find the jupyter_notebook_config.py file according to the file path:
insert image description here
3. Open it with Notepad or other software, and modify the contents inside. Through the search function in Notepad, find the following location:

insert image description here
4. Find the Google Chrome icon on the desktop, click the right mouse button, click Properties, and then copy the path of the target:
insert image description here
5. Then in step 3, add the following setting statement to the jupyter_notebook_config.py file (the path in the statement needs to be based on the actual situation Fill in, obtained in step 4). There is also the need for double slashes:

import webbrowser
webbrowser.register("chrome",None,webbrowser.GenericBrowser(u"C:\\Program Files\\Google\\Chrome\\Application\\chrome.exe"))
c.NotebookApp.browser = 'chrome'

6. After the setting is complete, save it. Restarting Jupyter_notebook will open with Chrome browser by default.

insert image description here
7. Finished, enter "jupyter notebook" on the command line to open it through Google Chrome:
insert image description here
8. You can also create a python file:
insert image description here
insert image description here

Guess you like

Origin blog.csdn.net/K_AAbb/article/details/127082055