最近爲了練習Kaggle上的一篇數據分析案例「泰坦尼克乘客獲取機率預測」,在windows上的jupyter notebook中各類報錯(多是依賴關係沒配好),因而萌發了在現有開發測試debian8.5虛擬機上搭建anaconda2的想法。
html
1. Installing Jupyter Notebook
官網(https://jupyter.readthedocs.io/en/latest/install.html)建議使用Anacondapython
1.1. 安裝anacondaweb
wget下載,而後以下安裝vim
bash Anaconda-latest-Linux-x86_64.sh
默認安裝目錄爲用戶家目錄下的anaconda2,如:/home/omm/anaconda2windows
安裝完成後就能執行jupyter notebook命令了,瀏覽器
列出anaconda當前包含哪些包:bash
conda -list
#我採用的是full安裝,全部該命令將會顯示206個包,ssh
而此時ssh鏈接到虛擬機上執行jupyter notebook命令的話,jupyter服務默認監聽本地8888端口(啓動後默認打開命令行下的web瀏覽器),遠端卻沒法瀏覽器鏈接到虛擬機的jupyter服務測試
2. 配置jupyter notebook 實現遠程訪問ui
2.1 生成jupyter配置文件
jupyter notebook --generate-config
2.2 配置訪問jupyter密碼保護
$ ipython Python 2.7.13 |Anaconda 4.3.1 (64-bit)| (default, Dec 20 2016, 23:09:15) Type "copyright", "credits" or "license" for more information. IPython 5.1.0 -- An enhanced Interactive Python. ? -> Introduction and overview of IPython's features. %quickref -> Quick reference. help -> Python's own help system. object? -> Details about 'object', use 'object??' for extra details. In [1]: from notebook.auth import passwd In [2]: passwd() Enter password: Verify password: Out[2]: 'sha1:28ebb93ec41b:96830638e989cde7191b..................'
2.3 修改jupyter配置文件
$vim ~/.jupyter/jupyter_notebook_config.py
主要修改以下幾個參數:
c.NotebookApp.ip='*' c.NotebookApp.password = u'sha1:ce...粘貼上一步生成的密文' c.NotebookApp.open_browser = False c.NotebookApp.port =8888
2.4 啓動jupyter
jupyter notebook
啓動信息以下:
omm@debiansible:~$ jupyter notebook [W 20:46:24.481 NotebookApp] WARNING: The notebook server is listening on all IP addresses and not using encryption. This is not recommended. [I 20:46:24.488 NotebookApp] Serving notebooks from local directory: /home/omm [I 20:46:24.488 NotebookApp] 0 active kernels [I 20:46:24.489 NotebookApp] The Jupyter Notebook is running at: http://[all ip addresses on your system]:8888/ [I 20:46:24.489 NotebookApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation).
2.5 遠程訪問
訪問地址http://ip:8888,輸入2.2節配置的密碼便可登陸