1、安装anaconda,推荐清华镜像:
https://mirror.tuna.tsinghua.edu.cn/help/anaconda/
如果需要用到虚拟环境,则安装nb_conda:pip install nb_conda
2、生成配置文件
jupyter notebook --generate-config
3、生成密码:远程访问
# ipython
from notebook.auth import passwd
passwd()
Enter password: #输入个密码,后续登录的时候需要
Verify password:
Out[2]: 'sha1:43b95b731276:5d330ee6f6054613b3ab4cc59c5048ff7c70f549'
4、修改配置文件
vim ~/.jupyter/jupyter_notebook_config.py
c.NotebookApp.ip='*' #设置访问notebook的ip,*表示所有IP,这里设置ip为都可访问
c.NotebookApp.notebook_dir = '/root/mashijie/share'#共享目录
c.NotebookApp.password = u'sha1:5df252f58b7f:bf65d53125bb36c085162b3780377f66d73972d1' #填写刚刚生成的密文
c.NotebookApp.open_browser = False # 禁止notebook启动时自动打开浏览器(在linux服务器一般都是ssh命令行访问,没有图形界面的。所以,启动也没啥用)
c.NotebookApp.port =8899 #指定访问的端口
c.NotebookApp.allow_remote_access = True
5、启动jupyter
jupyter notebook
还可以创建一个shell文件,方便启动和后台运行。
# start_jupyter.py
内容:
# source activate py3 # 如果用到名为py3的虚拟环境则加入这行
nohup jupyter notebook --allow-root > jupyter.log 2>&1&
6、6.在浏览器里输入你的地址 http://IP:8899/,然后输入密码,就能看到你共享的目录