This tutorial is based on Ubuntu Server 20.04 LTS. Other Linux systems are similar, and Python3 is installed by default.
1. Update the pip version (the old version of pip may cause unexpected problems)
sudo pip install --upgrade pip
2. Install jupyter
pip install jupyter
3. Configure environment variables
After the jupyter installation is complete, inputting jupyter notebook directly in the terminal may cause jupyter: command not found
an error. The reason is that there is no environment variable configured. It can be used by typing ~/.local/bin/jupyter-notebook
in the terminal , but an error will still be reported when the terminal is closed and opened again. Therefore, you need to simply configure the environment variables:
Add export PATH=~/.local/bin:${PATH} to the ~/.bashrc file , save the file and run source ~/.bashrc on the terminal to use jupyter notebook directly in the terminal.
4. Generate notebook configuration file
jupyter notebook --generate-config
.jupyter
This line of code will generate a folder in the current path , and the folder contains configuration files jupyter_notebook_config.py
.
5. Configure password
$ jupyter notebook password
Enter password: ****
Verify password: ****
[NotebookPasswordApp] Wrote hashed password to xxx/.jupyter/jupyter_notebook_config.json
Fill in the password and confirm the password, and a password hash will be generated under the configuration folder jupyter_notebook_config.json
.
6. Configurationjupyter_notebook_config.py
c.NotebookApp.ip = '*'
c.NotebookApp.password = "填入jupyter_notebook_config.json中的密码hash"
c.NotebookApp.open_browser = False
c.NotebookApp.port = 8888 #可自定义端口
c.NotebookApp.allow_remote_access = True
The default configuration files are all commented, so just copy and paste them in.
7. nohup starts jupyter notebook (background mount)
nohup jupyter notebook &
Log in to http://xxxx:8888 and enter the password to log in to jupyter notebook.
8. End process
ps -aux|grep jupyter #查找进程
kill -9 进程号 #结束进程