###服務器端配置python
- 在服務器生成jupyter配置文件
$jupyter notebook --generate-config
生成以後會獲得配置文件的路徑服務器
- 啓動jupyter,設置密碼
In [1]: from notebook.auth import passwd In [2]: passwd()
輸入、確認密碼以後,獲得了密文'shal:...'url
- 修改配置文件
打開以前生成的配置文件spa
添加以下代碼:.net
c.NotebookApp.ip = '*' c.NotebookApp.password = u'shal:...' #以前生成的密文 c.NotebookApp.open_browser = False c.NotebookApp.port = 3456 #隨便一個端口就能夠
- 重啓jupyter
若是用terminal啓動,不會彈出瀏覽窗口。code
服務器端配置完成ip
本地配置
注:服務器端啓動jupyter的terminal窗口不要關閉rem
在本地直接訪問 http://服務器地址:3456 ,輸入密碼就能夠進入jupyter了。terminal
###修改jupyter的python環境get
注:在本地打開的jupyter頁面本質上是服務器端的,因此設置的python環境也應爲服務器端的。
- 安裝ipykernel
pip install ipykernel
python -m ipykernel install --user --name python3.6 --display-name "python 3.6"
--name後爲環境名稱
--display-name後爲在jupyter中顯示的名字
###jupyter自動補全
注:均在服務器端進行安裝
- 安裝nbextensions
pip install jupyter_contrib_nbextensions -i https://pypi.mirrors.ustc.edu.cn/simple jupyter contrib nbextension install --user
- 安裝nbextensions_configurator
pip install --user jupyter_nbextensions_configurator jupyter nbextensions_configurator enable --user
- 重啓jupyter notebook
此時主頁會多出Nbextensions
按鈕,點擊後勾選Hinterland
,重啓jupyter就開啓自動補全了。
注:自動補全可能會與遠程訪問有衝突(不清楚原理),在自動補全配置完成以後,重啓服務器端jupyter,可能會有以下錯誤:
Traceback (most recent call last): File "/data/xxxxxx/anaconda3/envs/python3.6/lib/python3.6/site-packages/traitlets/traitlets.py", line 528, in get value = obj._trait_values[self.name] KeyError: 'allow_remote_access' ......
在最開始生成的配置文件中加入
c.NotebookApp.allow_remote_access = True
重啓jupyter便可。