目录
安装前准备
系统:ubuntu 18.04.1
工具:python3,pip3
步骤
1.安装Jupyter Notebook库
$ pip3 install jupyter
2.生成Jupyter Notebook配置文件
$ jupyter notebook --generate-config
#输出配置文件
该步骤生成的配置文件在后续的过程中用来配置服务器
3.设置Jupyter Notebook密码
$ python3
进入python3 shell,设置密码并得到密钥,改密码用于登录jupyter notebook
>>> from IPython.lib import passwd
>>> passwd()
Enter password:
Verify password:
#此处会输出密钥
4.修改配置文件
在配置文件目录下
$ c.NotebookApp.ip = '*'
# 所有绑定服务器的IP都能访问,若想只在特定IP访问,输入IP地址即可
$ c.NotebookApp.allow_root = True
# 为了安全,Jupyter默认不允许以root权限启动jupyter
$ c.NotebookApp.open_browser = False
# 不想在服务器上直接打开Jupyter Notebook,所以设置为False
$ c.NotebookApp.port = 8889
# 将端口设置成自己喜欢的,默认是8888
$ c.NotebookApp.password = 'sha1:...'
#输入上面加密后得到的密文
$ c.ContentsManager.root_dir = '/home/python/jupyter_notebook'
# 设置Jupyter目录,在后续Jupyter上创建目录均在该目录下
5.启动Jupyter服务器
$ jupyter notebook
6.测试
输入网址:ip:port(端口为配置文件里边设置的端口)
此处的密码为步骤3中设置的密码
问题
修改Jupyter目录权限
创建文件夹是提示错误:
原因是/home/python/jupyter_notebook
没有权限,在python
目录下设置一下权限即可
$ chmod 777 jupyter_notebook/
7.让jupyter在后台运行
运行
- 入门级:
jupyter notebook --allow-root > jupyter.log 2>&1 &
- 进阶:
nohup jupyter notebook --allow-root > jupyter.log 2>&1 &
终止
使用ps -a
得到进程号,kill -9 进程号
杀死进程
以上,可以在Jupyter上自由创作啦~