安装jupyter并配置远程访问
1. 服务器安装jupyter
如果你是python3的就使用如下命令安装:
python3 -m pip install --upgrade pip
python3 -m pip install jupyter
如果你的Python版本是Python 2:
python -m pip install --upgrade pip
python -m pip install jupyter
2. 生成配置文件
jupyter notebook --generate-config
文件默认位置:~/.jupyter/jupyter_notebook_config.py
3. 生成密码
命令行使用ipython
命令打开ipython,输入如下命令,创建一个密文的密码:
In [1]: from notebook.auth import passwd
In [2]: passwd()
Enter password:
Verify password:
Out[2]: 'sha1:ce23d945972f:34769685a7ccd3d08c84a18c63968a41f1140274'
把生成的密文‘sha:ce…’复制下来,接下来要进行访问配置。
4. 修改默认配置文件
vim ~/.jupyter/jupyter_notebook_config.py
进行如下修改:
c.NotebookApp.ip='*' # 或者'0.0.0.0'
c.NotebookApp.password = u'sha:ce...' # 刚才复制的那个密文'
c.NotebookApp.open_browser = False # 停止启动jupyter就进行浏览器访问
c.NotebookApp.port = 8888 # 随便指定一个端口
需要注意版本信息,如果notebook为5.6.0以下版本,c.NotebookApp.ip = '*'
,为以上版本,则设置为c.NotebookApp.ip = '0.0.0.0'
5. 启动jupyter notebook
jupyter notebook
后面会提示使用root用户启动需要加入参数:
jupyter notebook --allow-root
终止jupyter服务:Ctrl + C
6. 本机远程访问
直接从本地浏览器直接访问http://address_of_remote:8888
就可以看到jupyter的登陆界面。