Notes|Jupyter|Installing Jupyter in a Linux environment and accessing it remotely

1. Install Jupyter

Install the jupyter package using pip

$ pip install jupyter

2. Modify the configuration file

2.1 Write the Jupyter configuration file to the home directory

Go to the folder where the pip executable file is located, generate the jupyter configuration file, and the configuration file will be generated in the .jupyterfolder :

$ jupyter-notebook --generate-config
Writing default config to: /home/my_user/.jupyter/jupyter_notebook_config.py
2.2 Configure Jupyter password

Create get_passwd.pya file and add the following content to it:

$ vim get_passwd.py
from notebook.auth import passwd
pwd = passwd()
print(pwd)

Execute this script after adding:

$ python get_passwd.py

After setting the password, a password string will be printed and stored.

Modify the configuration file and add the following content anywhere:

$ vim jupyter_notebook_config.py
c.NotebookApp.ip = '*'  # 允许任何 ip 去访问 Jupyter Notebook
c.NotebookApp.open_browser = False  # 不在 Linux 下打开浏览器
c.NotebookApp.port = 8888  # 指定 Jupyter 默认的 8888 端口
c.NotebookApp.allow_remote_access = True  # 允许远程控制
c.NotebookApp.notebook_dir = u'路径'  # 设置开发 Jupyter Notebook 时打开的路径
c.NotebookApp.password = u'xxxxxxxxxx'  # 刚才存储的密码字符串

3. System configuration

If the firewall is enabled, you need to enable Jupyter's default running port:

$ firewall-cmd --zone=public --add-port=8888/tcp --permanent  # 添加 Jupyter 的默认运行端口
$ firewall-cmd --reload  # 重新载入配置

4. Start Jupyter

$ nohup jupyter-notebook >> /home/txjiang/.jupyter/jupyter.log 2>&1 &

  • Install the Nbextensions extension pack
$ pip install jupyter_contrib_nbextensions
$ jupyter contrib nbextension install --user
$ jupyter nbextension enable codefolding/main

Guess you like

Origin blog.csdn.net/Changxing_J/article/details/129737012