Install jupyter notebook in Anaconda environment, create shortcuts, add/delete kernels, configure theme colors and toolbars [Update]

Install jupyter notebook, create shortcuts, add/remove kernels, configure theme colors and toolbars in Anaconda environment

Tip: This article is a record of a series of successful installation processes such as Anaconda + cuda + cudnn + TensorFlow + pytorch + jupyter notebook. Some steps have version number requirements, such as TensorFlow and cuda + cudnn. All article links will be posted later. Up, looking forward to ing
Nanny-level tutorial (doge

Article directory

  • Install jupyter notebook, create shortcuts, add/remove kernels, configure theme colors and toolbars in the Anaconda environment
  • Preface
  • 1. Install jupyter notebook
    • 1.1 Enter the newly created virtual environment
    • 1.2 Install ipython
    • 1.3 Install jupyter
    • 1.4 Add Jupyter Notebook shortcut
    • 1.5 View Jupyter Notebook shortcuts
  • 2. Configure jupyter notebook
    • 2.1 Preparation
    • 2.2 Open the file that sets the default opening path of jupyter notebook
    • 2.3 Configure the files in the default opening path of jupyter notebook
    • 2.4 Modify the default opening path corresponding to the jupyter shortcut in the “Start” menu
    • 2.5 Build/delete the Anaconda virtual environment kernel
    • 2.6 Set jupyter notebook theme color (can be skipped)
    • 2.7 Set up the jupyter notebook toolbar (can be skipped)
  • 3. Detailed description of some miscellaneous items
    • 3.1 How to create a shortcut to jupyter desktop

Foreword

Prerequisite: Anaconda3 has been installed

1. Install jupyter notebook

1.1 Enter the newly created virtual environment

Enter Anaconda Prompt and enter the following command to view the name of the created virtual environment.

conda env list

Continue to enter the following command in Anaconda Prompt to enter the virtual environment where jupyter notebook needs to be installed.

activate tensorflow

As shown below, the name of the new environment I created is tensorflow.

1.2 Install ipython

Continue to enter the following command in Anaconda Prompt to start installing ipython.

conda install ipython

You need to confirm y in the middle, and then display as follows, ipython is installed successfully.

1.3 Install jupyter

Continue to enter the following command in Anaconda Prompt to start installing jupyter. You also need to confirm y.

conda install jupyter

1.4 Add Jupyter Notebook shortcut

Tips: This method creates a shortcut in the Windows menu, and then opens the search box every time you search, which is very convenient.
Please see section 3.1 below for detailed steps that need to be placed on the desktop.
Continue to enter the following commands in Anaconda Prompt and add a Jupyter Notebook shortcut.

ipython kernelspec install-self-user

1.5 View Jupyter Notebook shortcuts

Open the windows menu and find the Jupyter Notebook (tensorflow) shortcut in the picture below, click to enter.

If jupyter can be opened successfully, the shortcut is created successfully.
Then, we found that the default opening path of jupyter is as shown below. This default opening path can be changed. Next, we set the path we want jupyter to open.

2. Configure jupyter notebook

2.1 Preparation

First, create a specified path. If you already have one, you don’t need to create it.

For example, the picture below shows an existing folder that I want to open by default every time. Then its path is D:\Projects\JupyterProject (remember the default opening path you want to specify, which will be used below).

2.2 Open the file that sets the default opening path of jupyter notebook

Continue to enter the following command in the virtual environment that needs to be configured, and find the default path management file in the current environment.

jupyter notebook --generate-config

From the above figure, we found that the path is: C:\Users\lk.jupyter\jupyter_notebook_config.py

Don't worry about this y/N, copy the path first, then ctrl + C to end the process.
Then find this path in the file explorer and open the jupyter_notebook_config.py file.

2.3 Configure the file in the default opening path of jupyter notebook

In the file shown above, search with ctrl + F to find the code in the red box in the picture below, then delete the comment ‘#’ in front of the code, and then add the default opening location you want after ‘=’. That is, the path I just asked you to write down in 2.1 Preparation, and then save it.
However, I found that after completing this step, clicking the shortcut of Jupyter Notebook (tensorflow) still failed to specify the required default opening path. Because the above modification only completes the modification of the starting path when opening Jupyter Notebook from Anaconda. When opening Jupyter Notebook from the start menu using the jupyter notebook shortcut, the starting path is still the default user folder and needs to be modified to the specified folder path. So, you still need to continue the following operations.

2.4 Modify the default opening path corresponding to jupyter shortcut in the “Start” menu

Right-click, open the file location, then right-click again, click Properties, select Shortcut, delete the selected blue area behind the target (T) column, and then click OK. (Do not click X’ to exit)



After completion, open the jupyter shortcut in Windows 11. The default opening path of jupyter is the path we want to open.

2.5 Build/delete the Anaconda virtual environment kernel

1) Execute the code and install ipykernel, which provides IPython kernel for Jupyter. Download it from Douban source here.

pip install ipykernel -i https://pypi.douban.com/simple


2) First let’s talk about how to delete it. When this kernel virtual environment is no longer needed, we need to do this:

Reprinted from: https://www.jianshu.com/p/bbd269e45cb1
1 Open Anaconda Prompt
2 Enter jupyter kernelspec list to view the installed kernel and location
3 Enter it according to the displayed path, delete the folder, and restart jupyter notebook.

3) Next, let’s talk about how to add Anaconda’s new virtual environment to Jupyter Notebook.

1 Open Anaconda Prompt
2 Enter the activate command to enter the virtual environment that needs to be added.
3 Add the virtual environment to Jupyter through the command: python -m ipykernel install –user –name=tensorflow

If the information is printed, as shown below, it means that the virtual environment named tensorflow was successfully added to the jupyter kernel.

Installed kernelspec tensorflow in C:\Users\lk\AppData\Roaming\jupyter\kernels\tensorflow

Log in to jupyter notebook and find that it has been added.

2.6 Set jupyter notebook theme color (can be skipped)

Reprinted from: https://www.jianshu.com/p/72ae0314e29a
The final effect is as follows, you can skip it if you don’t like it.

1) Enter the following command in Anaconda Prompt to install the custom theme of jupter notebook.

pip install --upgrade jupyterthemes



Successfully, the installation was successful.

2) Continue to enter the following commands in Anaconda Prompt to view optional themes.

jt -l

3) Continue to enter the following commands in Anaconda Prompt to set the theme.

jt -t monokai -f fira -fs 13 -cellw 90% -ofs 11 -dfs 11 -T -N

Among them -f (indicates font) -fs (font size) -cellw (screen ratio or width) -ofs (font size of the output section) -T (display toolbar) -N (display own host name).


Then just restart jupyter notebook, the effect is as follows. If you don’t like it, you can try other themes. Just change the monokai in the code to the themes shown in the second step.


Tips: If you don’t like it, enter the following command to restore the system default theme.

jt -r

2.7 Set up jupyter notebook toolbar (can be skipped)

Reprinted from: https://blog.csdn.net/Itsme_MrJJ/article/details/116013487
The effect is as shown below. If you don’t like it and don’t need it, don’t read it.
1) Enter the following command in Anaconda Prompt to install the plug-in nbextensions.

pip install jupyter_contrib_nbextensions



Successfully, the installation was successful. No problem, continue to enter the following two lines of commands in sequence.

jupyter contrib nbextension install
pip install yapf

2) Then open jupyter notebook and click in the order shown below.

The effect is as follows:

Before code beautification:

After code beautification:

3. Detailed description of some miscellaneous items

3.1 How to create a shortcut to jupyter desktop

Follow 1.4 Add Jupyter Notebook shortcut to add the shortcut in the windows menu, and then follow the following steps.