ubuntu 安裝jupyter,並且設定遠端訪問
阿新 • • 發佈:2018-11-12
sudo apt-get install software-properties-common
sudo add-apt-repository ppa:jonathonf/python-3.6
sudo apt-get update
sudo apt-get install python3.6
sudo apt-get install python3-pip
sudo apt-get install python-pip
pip -V
pip3 -V
pip3 升級
sudo pip3 install --upgrade pip
安裝jupyter notebook
- 檢查是否有安裝jupyter notebook,終端輸入jupyter notebook,如果報錯就是沒有啦,那麼就要用下面命令安裝。
$sudo pip install pyzmq
$sudo pip install tornado
$sudo pip install jinja2
$sudo pip install jsonschema
$sudo pip install jupyter
- 生成配置檔案
jupyter notebook --generate-config
3. 生成密碼(後續寫配置檔案、登入Jupyter notebook需要)
開啟python終端
In [1]: from IPython.lib import passwd
In [2]: passwd()
Enter password:
Verify password:
Out[2]: 'sha1:0e422dfccef2:84cfbcbb3ef95872fb8e23be3999c123f862d856'
- 修改預設配置檔案
vim ~/.jupyter/jupyter_notebook_config.py
在檔案頭新增
c.NotebookApp.ip='*' c.NotebookApp.password = u'sha:ce...剛才複製的那個密文' c.NotebookApp.open_browser = False c.NotebookApp.port =8888 #隨便指定一個埠 c.IPKernelApp.pylab = 'inline' c.NotebookApp.allow_remote_access = True
- 啟動jupyter notebook
jupyter notebook
若出現以下錯誤:
解決方法
在預設的配置檔案中新增以下程式碼即可訪問
c.NotebookApp.allow_remote_access = True
使用supervisor 對notebook進行管理
[program:notebook]
command=jupyter notebook --allow-root
directory=/home/ubuntu/notebook/
user=root
autostart=true
autorestart=true
redirect_stderr=True
stopasgroup=true
killasgroup=true