centos 7 jupyter配置

一、生成jupyter的配置文件

  • 执行命令
jupyter notebook --generate-config
  • 会在用户目录下生成文件
/home/usrname/.jupyter/jupyter_notebook_config.py

二、生成密钥

  • 打开ipython或者是python
In [1]:from notebook.auth import passwd
In [2]:passwd()
# 该密码将是你浏览器访问服务器时需要输入的密码
Enter password: 123
Verify password:123
Out[2]: 'sha1:8361f5f08937:081cdf40730cb5548e2c213ddd36813a5313192f'

三、修改配置文件

vim ~/.jupyter/jupyter_notebook_config.py
# jupyter默认打开的文件夹,也是该juputer的根文件夹,如果不设置,将会打开用户目录
c.NotebookApp.notebook_dir = '/Data/'
# 运行root账号远程登录访问
c.NotebookApp.allow_root = True
# 服务器的IP地址,切记使用'localhost'
c.NotebookApp.ip = '172.*.*.168'
# 禁用服务器上的浏览器
c.NotebookApp.open_browser = False
# 由python产生的密码hash值,由第二步生成
c.NotebookApp.password = u'sha1:a800c84026a2:1e*****2d1ceec0dd4dac452a164ceb'
# jupyter服务运行的端口号
c.NotebookApp.port = 8888

四、打开配置文件中设定的端口号

firewall-cmd --zone=public --add-port=8888/tcp --permanent
sudo systemctl restart firewalld

五、开启jupyter后端运行

nohup jupyter notebook --allow-root

六、浏览器访问jupyter

  • 浏览器输入ip:port,输入密码123即可访问
172.*.*.168:8888

猜你喜欢

转载自blog.csdn.net/KIJamesQi/article/details/115302782