日本免费高清视频-国产福利视频导航-黄色在线播放国产-天天操天天操天天操天天操|www.shdianci.com

學無先后,達者為師

網站首頁 編程語言 正文

ubuntu安裝jupyter并設置遠程訪問的實現(xiàn)_python

作者:武老師 ? 更新時間: 2022-06-02 編程語言

Jupyter Notebook是一個Web應用程序,允許您創(chuàng)建和共享包含實時代碼,方程,可視化和說明文本的文檔。

簡單的介紹就是:Jupyter Notebook是Ipython的升級版,而Ipython可以說是一個加強版的交互式 Shell,也就是說,它比在terminal里運行python會更方便,界面更友好

環(huán)境:

  • Ubuntu16.04 64位

安裝pip

(1)更新和升級包

sudo apt-get update  
sudo apt-get upgrade

(2)安裝pip

sudo apt-get install python-pip3

安裝Jupyter

(1)升級pip3

sudo pip3 install --upgrade pip3

(2)安裝Jupyter

sudo pip3 install jupyter

注意這里一定要有sudo。否則Jupyter安裝會失敗
安裝成功會顯示下面的信息

注意:如果提示

運行命令:

sudo pip3 install -vU setuptools

再次安裝

生成一個 notebook 配置文件

默認情況下,配置文件 ~/.jupyter/jupyter_notebook_config.py 并不存在,需要自行創(chuàng)建。使用下列命令生成配置文件:

jupyter notebook --generate-config

如果是 root 用戶執(zhí)行上面的命令,會發(fā)生一個問題:

Running as root it not recommended. Use --allow-root to bypass.

提示信息很明顯,root 用戶執(zhí)行時需要加上?--allow-root?選項。

jupyter notebook --generate-config --allow-config

執(zhí)行成功后,會出現(xiàn)下面的信息:

Writing default config to: /root/.jupyter/jupyter_notebook_config.py

生成密碼

自動生成

從 jupyter notebook 5.0 版本開始,提供了一個命令來設置密碼:jupyter notebook password,生成的密碼存儲在 jupyter_notebook_config.json

$ jupyter notebook password
Enter password:  ****
Verify password: ****
[NotebookPasswordApp] Wrote hashed password to /Users/you/.jupyter/jupyter_notebook_config.json

手動生成

除了使用提供的命令,也可以通過手動安裝,我是使用的手動安裝,因為jupyter notebook password 出來一堆內容,沒耐心看。打開 ipython 執(zhí)行下面內容:

In [1]: from notebook.auth import passwd
In [2]: passwd()
Enter password:
Verify password:
Out[2]: 'sha1:67c9e60bb8b6:9ffede0825894254b2e042ea597d771089e11aed'

sha1:67c9e60bb8b6:9ffede0825894254b2e042ea597d771089e11aed 這一串就是要在 jupyter_notebook_config.py 添加的密碼。

c.NotebookApp.password = u'sha1:67c9e60bb8b6:9ffede0825894254b2e042ea597d771089e11aed'
3. 修改配置文件

?修改配置文件

jupyter_notebook_config.py 中找到下面的行,取消注釋并修改。

c.NotebookApp.ip='*'#163行
c.NotebookApp.password = u'sha:ce...剛才復制的那個密文'  #217行
c.NotebookApp.open_browser = False#208
c.NotebookApp.port =8888 #可自行指定一個端口, 訪問時使用該端口228行

以上設置完以后就可以在服務器上啟動 jupyter notebook,jupyter notebook, root 用戶使用 jupyter notebook --allow-root。打開 IP:指定的端口, 輸入密碼就可以訪問了。

需要注意的是不能在隱藏目錄 (以 . 開頭的目錄)下啟動 jupyter notebook, 否則無法正常訪問文件。

原文鏈接:https://www.cnblogs.com/wu-chao/p/8419889.html

欄目分類
最近更新