在伺服器端上安裝Jupyter
最近見到周圍有些人使用Jupyter,網頁端程式設計感覺挺爽。有需要的童鞋可以試著安裝在伺服器,謹此記錄。
首先應該是需要安裝一個anaconda
Anaconda安裝步驟[1]
官網地址: https://www.anaconda.com/download/#linux
Anaconda3-5.3.0-Linux-x86_64.sh depends on what you download
wget https://repo.anaconda.com/archive/Anaconda3-5.3.0-Linux-x86_64.sh
bash Anaconda3-5.3.0-Linux-x86_64.sh -u
根據提示按ENTER
In order to continue the installation process, please review the license
agreement.
Please, press ENTER to continue
>>>
根據提示輸入yes,同意license agreement
... ... kerberos (krb5, non-Windows platforms) A network authentication protocol designed to provide strong authentication for client/server applications by using secret-key cryptography. cryptography A Python library which exposes cryptographic recipes and primitives. Do you approve the license terms? [yes|no] >>> yes
直接ENTER鍵,用預設的安裝路徑
Anaconda2 will now be installed into this location:
/root/anaconda3
- Press ENTER to confirm the location
- Press CTRL-C to abort the installation
- Or specify a different location below
[/root/anaconda3] >>>
寫入環境變數,直接輸入yes
... ... installing: zlib-1.2.8-3 ... installing: anaconda-4.4.0-np112py27_0 ... installing: conda-4.3.21-py27_0 ... installing: conda-env-2.6.0-0 ... Python 2.7.13 :: Continuum Analytics, Inc. creating default environment... installation finished. Do you wish the installer to prepend the Anaconda2 install location to PATH in your /root/.bashrc ? [yes|no] [no] >>> yes
生效.bashrc檔案
[[email protected] tmp]# source ~/.bashrc
輸入python,驗證環境
Python 3.6.5 |Anaconda 4.4.0 (64-bit)| (default, Apr 10 2018, 17:09:15)
[GCC 4.4.7 20150623 (Red Hat 4.4.7-1)] on linux
Type "help", "copyright", "credits" or "license" for more information.
Anaconda is brought to you by Continuum Analytics.
Please check out: http://continuum.io/thanks and https://anaconda.org
>>>
但是在這裡嘻哈遇到了似乎是沒有配置成功的問題, 解決方案參考[2]
export PATH=~/anaconda3/bin:$PATH
需要安裝jupyter,理論上安裝好anaconda後就能夠運行了,可以試試conda命令是否有效,未找到jupyter命令則pip安裝
pip install jupyter
至此安裝應該完成了,之後需要啟動並且稍微配置一下下,之後有空寫個一鍵包放在git上
配置[3]
先安裝一些package+配置
pip install ipython
pip install jupyter
jupyter notebook –generate-config –allow-root
生成密碼
[[email protected] ~]# ipython
Python 3.5.2 (default, Aug 4 2017, 02:13:48)
Type 'copyright', 'credits' or 'license' for more information
IPython 6.1.0 -- An enhanced Interactive Python. Type '?' for help.
In [1]: from notebook.auth import passwd
In [2]: passwd()
Enter password:
Verify password:
Out[2]: 'sha1:5311cd8b9da9:70dd3321fccb5b5d77e66080a5d3d943ab9752b4'
修改生成的配置檔案,將以下幾個地址修改如下,並且去掉該行前的#,使其生效
vi /root/.jupyter/jupyter_notebook_config.py 或者
vi ~/.jupyter/jupyter_notebook_config.py
c.NotebookApp.ip='*'
c.NotebookApp.password = u'sha1:5311cd8b9da9:70dd3321fccb5b5d77e66080a5d3d943ab9752b4'
c.NotebookApp.open_browser = False
c.NotebookApp.port =9999 #隨便指定一個埠,使用預設8888也可以
訪問jupyter notebook
現在命令列下開啟服務,檢視系統指定的是哪個埠,有可能是9999
jupyter notebook --ip=0.0.0.0 --no-browser --allow-root
之後就能用ip:9999訪問了 EOF
One more thing
主要參考文獻
在伺服器端升級python並安裝Jupyter
Centos7安裝Anaconda
在centos7伺服器上安裝anaconda和jupyter notebook
跟我一起學python第二講 開發工具Jupyter Notebook安裝和遠端訪問設定
其他參考:
https://blog.csdn.net/lzc4869/article/details/78625233
http://www.edu-ing.cn/go.php?https://cn.aliyun.com/jiaocheng/433136.html?spm=5176.100033.2.7.3a5d8fc9ixUljg
http://www.edu-ing.cn/go.php?https://cn.aliyun.com/jiaocheng/433318.html?spm=5176.100033.2.9.3a5d8fc9ixUljg
Jupyter使用