mac远程linux的ide,Jupyter notebook在mac:linux上的配置和远程访问
IPython 和 Jupyter
IPython 通常指的是一個(gè) Python REPL(交互式解釋器) shell。提供了遠(yuǎn)比 Python shell 強(qiáng)大的 shell 環(huán)境。IPython 是 Iteractive Python shell的縮寫。 Notebook 是一個(gè)基于 IPython 的 web 應(yīng)用。
截止 IPython 3.0 ,IPython 變得越來越臃腫,因此, IPython 4.x 后,IPython被分離成為了IPython kernel's Jupyter(IPython shell combined with jupyter kernel) 和Jupyter subprojects ,Notebook 是 Jupyter 的一個(gè) subproject 。官方將此稱為The Big Split?。#reference-The Big Split?
IPython 把與語言無關(guān)(language-agnostic)的 components 和 Python 解釋器剝離,獨(dú)立為Jupyter發(fā)行。因此,Jupyter 可以和 Python 之外的解析器結(jié)合,提供新的、強(qiáng)大的服務(wù)。比如 Ruby REPL 環(huán)境 IRuby 和 Julia REPL 環(huán)境 IJulia。
因此,Jupyter 和 IPyhon 指代同一個(gè)項(xiàng)目, Jupyter 特指 Ipython4 后的, 非python kernel框架。
Jupyter Notebook已經(jīng)逐漸取代IDE成為了多平臺上寫簡單Python腳本或應(yīng)用的幾家選擇。
Jupyter Notebook可以通過pip/pip3安裝:
sudopip3 installjupyter
然后在目標(biāo)文件夾目錄下,輸入指令jupyter notebook開啟服務(wù),可在瀏覽器地址localhost:8888中訪問主頁
允許遠(yuǎn)程訪問
我之前在訓(xùn)練一些簡單的svm模型的時(shí)候,因?yàn)閿?shù)據(jù)量大,訓(xùn)練時(shí)間慢,導(dǎo)致自己的macbook在訓(xùn)練過程中一直無法做別的事情,就動了在遠(yuǎn)程Linux虛擬機(jī)上裝一套Jupyter Notebook然后將耗時(shí)很長的訓(xùn)練操作放在遠(yuǎn)程機(jī)器上做。
在本地,我們訪問localhost:8888就能看到Jupyter Notebook的本地主頁,但是在遠(yuǎn)程訪問中,并不能直接這么做。因此需要以下一些操作:
1. 生成一個(gè) notebook 配置文件
默認(rèn)情況下,配置文件 ~/.jupyter/jupyter_notebook_config.py 并不存在,需要自行創(chuàng)建。使用下列命令生成配置文件:
jupyter notebook --generate-config
如果是 root 用戶執(zhí)行上面的命令,會發(fā)生一個(gè)問題:
Running as root it not recommended.
Use --allow-root to bypass.
提示信息很明顯,root 用戶執(zhí)行時(shí)需要加上 –allow-root 選項(xiàng)。
jupyter notebook --generate-config --allow-config
執(zhí)行成功后,會出現(xiàn)下面的信息:
Writing default config to: /root/.jupyter/jupyter_notebook_config.py
2. 生成密碼
自動生成
從 jupyter notebook 5.0 版本開始,提供了一個(gè)命令來設(shè)置密碼: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
手動生成
除了使用提供的命令,也可以通過手動安裝,我是使用的手動安裝,因?yàn)閖upyter notebook password 出來一堆內(nèi)容,沒耐心看。打開 ipython 執(zhí)行下面內(nèi)容:
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='*'
c.NotebookApp.password = u'sha:ce... # 剛才復(fù)制的那個(gè)密文'
c.NotebookApp.open_browser = False
c.NotebookApp.port =8888 # 可自行指定一個(gè)端口, 訪問時(shí)使用該端口
以上設(shè)置完以后就可以在服務(wù)器上啟動 jupyter notebook,jupyter notebook, root 用戶使用 jupyter notebook --allow-root。打開 IP:指定的端口(默認(rèn)為8888), 輸入密碼就可以訪問了。
同時(shí)支持python2和python3
先安裝Python2和Python3的ipython notebook
pip2 installipython notebook
pip3 installipython notebook
分別用各自的ipython執(zhí)行下面的指令
ipython2 kernelspec install-self
ipython3 kernelspec install-self
就能在ipython notebook里面同時(shí)使用兩種版本的Python了
創(chuàng)作挑戰(zhàn)賽新人創(chuàng)作獎(jiǎng)勵(lì)來咯,堅(jiān)持創(chuàng)作打卡瓜分現(xiàn)金大獎(jiǎng)總結(jié)
以上是生活随笔為你收集整理的mac远程linux的ide,Jupyter notebook在mac:linux上的配置和远程访问的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 中芯国际第二季度财报发布 营收9.3
- 下一篇: linux查看文件位置命令bwd,lin