1、安装jupyter
pip install jupyter
2、生成配置文件
jupyter notebook --generate-config
3、配置文件的路径为:
~/.jupyter/jupyter_notebook_config.py
4、进入python环境,依次执行:
python
from notebook.auth import passwd
passwd()
执行上述命令后会让你设置一个密码,这个密码是你在远程windows上访问时需要的密码。输入两次密码后会生成一个密钥:
‘sha1:d66351142f0a:9eea3d7f99e434a6837f5e73af18d03cf0353392’
5、退出python环境
exit()
6、修改配置文件
vim ~/.jupyter/jupyter_notebook_config.py
修改1、
c.NotebookApp.password = u’sha1: d66351142f0a:9eea3d7f99e434a6837f5e73af18d03cf0353392’
修改2、
c.NotebookApp.ip = ‘*’
修改3、
c.NotebookApp.open_browser = False
修改4、
c.NotebookApp.port = 12345(自己任意设置)
修改5、
c.NotebookApp.allow_remote_access = True
7、启动jupyter
jupyter notebook
8、访问
linux服务器的ip:12345
如192.168.3.210:12345
PS:12345是刚在配置文件设置的端口
参考:https://jingyan.baidu.com/article/c33e3f48de2308ea15cbb5d4.html
一键配置脚本
将下面脚本内容保存为jupyter_config_and_install.sh,然后再需要配置的服务器运行bash jupyter_config_and_install.sh,中间会提示让你设置密码,可以按回车跳过。
#!/bin/bash
# Step 1: Install Jupyter
pip install jupyter
# Step 2: Generate configuration file
jupyter notebook --generate-config
# Step 3: Configuration file path
config_file=~/.jupyter/jupyter_notebook_config.py
# Step 4: Generate password hash
password_hash=$(python - <<END
from notebook.auth import passwd
print(passwd())
END
)
# Step 5: Modify configuration file
cat <<EOT >> $config_file
c.NotebookApp.password = u'$password_hash'
c.NotebookApp.ip = '*'
c.NotebookApp.open_browser = False
c.NotebookApp.port = 12345
c.NotebookApp.allow_remote_access = True
EOT
# Step 6: Start Jupyter Notebook
jupyter notebook