Jupyter Notebook installation process record

I accidentally discovered Jupyter Notebook, a compiler that is popular in machine learning. I just wanted to learn about machine learning, so I downloaded and installed one.

1. Install a python, preferably a newer version. I installed py3.8.

2. Update pip to the latest

python -m pip install -U pip setuptools

3. After the pip update is completed, start installing jupyter notebook. I use pip to install and do not use Anaconda to install.

#For Python2
pip install jupyter

#For Python3
pip3 install jupyter

4. After the installation is complete, configure the file path of jupyter to solve the error of Permission denied: Untitled.ipynb.

(1) Configuration file path:

Enter the following command in cmd to generate the configuration file. After the command is completed, the path to the configuration file will be displayed:

jupyter notebook --generate-config

(2) Follow the path and find the configuration file jupyter_notebook_config.py

(3) Open the configuration file and modify the file path:

Find the keyword in the configuration file: c.NotebookApp.notebook_dir, replace the equal sign with the path you want to store the project file. Note that the format is u'file path', and the letter u cannot be missing. After saving the modification, you need to close the current cmd window, open a new cmd, and then start jupyter, otherwise the changes will not take effect.

 If this step is not configured, an error will be reported when creating a new py3 file in the notebook: 

Permission denied: Untitled.ipynb

5. Configure the kernel path to solve the kernel error.

After the installation is completed, if the kernel path is not configured, a kernel error will appear when starting jupyter and the code will not run. This kind of problem is usually caused by a problem with the kernel.json file.

(1) Run the command to check the current kernel installation path: 

jupyter kernelspec list

 Find the kernel.json file according to the displayed path, and then open it. Modify as shown below

{
 "argv": [
  "C:\\Python38\\python.exe",   (修改为自己想使用的python环境的路径,我当前选的是python38)
  "-m",
  "ipykernel_launcher",
  "-f",
  "{connection_file}"
 ],
 "display_name": "Python 3 (ipykernel)",
 "language": "python",
 "metadata": {
  "debugger": true
 }
}

Check whether the path file of the python editor is the same as the installation path. If not, enter

python -m ipykernel install --user

Just reinstall the kernel.

 Finally restart jupyter notebook

Start command in cmd:  jupyter notebook

Guess you like

Origin blog.csdn.net/x1987200567/article/details/124732412