一、jupyter目錄在哪
jupyter目錄由jupyter notebook管理,它是一個基於web的互動式計算環境,支持運行各種編程語言並以notebook的形式組織數據、代碼、文本和圖像。在安裝jupyter notebook後,啟動jupyter notebook,在瀏覽器中打開notebook主界面,在右上角點擊New按鈕,可以新建一個notebook,它的默認工作目錄就是當前系統用戶的home目錄。
二、怎麼顯示jupyter目錄
jupyter notebook默認不顯示目錄,只顯示notebook文件。如果需要在notebook中顯示目錄,可以使用jupyter_contrib_nbextensions提供的Tree View插件。這個插件可以在側邊欄中顯示notebook文件和目錄。安裝這個插件需要使用pip命令:
!pip install jupyter_contrib_nbextensions
!jupyter contrib nbextension install --user
!jupyter nbextension enable treeview/main
安裝完後,在jupyter notebook的主菜單中會多出一個Nbextensions選項卡,選擇TreeView選項,在右側勾選Tree和Collapsible headings兩個選項,保存設置,重新載入notebook,就能在側邊欄中看到目錄了。
三、jupyter目錄樹
jupyter目錄樹是指將某個目錄下的notebook文件以樹形結構展示在notebook中。有時候項目中的notebook文件會很多,如果需要選擇某個文件進行編輯,就需要不斷地在notebook列表中滾動,非常不便。jupyter_contrib_nbextensions提供了Tree Filter、Variable Inspector和Execute Time插件可以實現在notebook中顯示目錄樹。安裝這三個插件的步驟和TreeView插件類似,安裝命令如下:
!pip install jupyter_contrib_nbextensions
!jupyter contrib nbextension install --user
!jupyter nbextension enable tree_filter/main
!jupyter nbextension enable varInspector/main
!jupyter nbextension enable execute_time/ExecuteTime
安裝完後,在jupyter notebook的主菜單中進入Nbextensions選項卡,在Tree Filter選項中可以輸入notebook名稱或作者進行過濾,Variable Inspector可以查看當前notebook中的變數和函數,Execute Time可以顯示每個單元格的執行時間。
四、jupyter目錄怎麼批量刪除
jupyter目錄支持批量刪除的方式有多種,下面兩種方式比較容易實現:
1、使用os模塊
import os
import glob
from pathlib import Path
# 指定目錄
folder_path = Path('./目錄名稱')
# 獲取所有的.ipynb文件路徑
file_list = glob.glob(str(folder_path / '*.ipynb'))
# 刪除所有的.ipynb文件
for file_path in file_list:
os.remove(file_path)
2、使用IPython.display模塊和IPython.lib.backgroundjobs模塊
from IPython.display import display, Javascript
from IPython.lib.backgroundjobs import BackgroundJobManager
def delete_files_local(filter):
job_manager = BackgroundJobManager()
cmd = f"""!find ./ -name '{filter}' -exec rm "{{}}" \;"""
job_manager.new_job(cmd).start()
delete_files_local('*.ipynb')
五、jupyter目錄怎麼設置
jupyter目錄的設置可以通過jupyter_notebook_config.py文件進行配置。該文件通常位於~/.jupyter/目錄下。如果該文件不存在,可以使用以下命令生成:
jupyter notebook --generate-config
可以在該文件中添加自定義設置,如下是一些比較常用的配置:
c.NotebookApp.ip = '*'
c.NotebookApp.port = 8888
c.NotebookApp.open_browser = False
c.NotebookApp.notebook_dir = '/home/user/path/to/notebook'
其中,c.NotebookApp.ip可以設置jupyter notebook的IP地址(默認為localhost);c.NotebookApp.port可以設置jupyter notebook的埠號(默認為8888);c.NotebookApp.open_browser可以設置是否在啟動jupyter notebook時自動打開瀏覽器(默認為True);c.NotebookApp.notebook_dir可以設置jupyter notebook的主目錄。
六、jupyter目錄怎麼打
jupyter目錄可以在jupyter notebook中打開,也可以在命令行中使用瀏覽器打開。如果需要在命令行中打開jupyter目錄,可以使用以下命令:
jupyter notebook --no-browser --port 8888
該命令將在本地啟動jupyter notebook,並監聽8888埠。如果需要在其他計算機中打開jupyter目錄,可以使用ssh隧道,具體方法如下:
1、在遠程計算機中啟動jupyter notebook,並指定監聽本地IP地址的某個埠,如8888
jupyter notebook --ip=127.0.0.1 --port=8888
2、在本地計算機中使用ssh隧道將指定的埠映射到本地計算機的某個埠,如8889
ssh -N -f -L localhost:8889:localhost:8888 user@remote_host
3、在本地計算機的瀏覽器中訪問localhost:8889,即可訪問遠程計算機上的jupyter目錄。
七、jupyter目錄名稱無效
jupyter目錄名稱無效是因為非法字元或與系統保留關鍵字衝突。jupyter notebook規定目錄名稱只能使用字母、數字、下劃線和連字元,不能以連字元開頭或結尾。
八、jupyter目錄名稱無效是怎麼回事
如果使用了非法字元或系統保留關鍵字,jupyter notebook會提示目錄名稱無效。以下是一些不合法的目錄名稱示例:
my notebook # 包含空格
my/notebook # 包含斜杠
my-notebook- # 以連字元結尾
-delete # 以連字元開頭
九、jupyter目錄二級標題打不出
如果在jupyter notebook中使用markdown語法添加標題時,發現二級標題打不出。這可能是因為在標題前沒有使用空格。正確的二級標題語法應該如下:
## 二級標題
十、jupyter目錄不顯示選取
如果jupyter notebook中的目錄不顯示選取,則可以嘗試使用以下命令更新jupyter_contrib_nbextensions:
pip install --upgrade jupyter_contrib_nbextensions
更新完成後,重啟jupyter notebook即可。
原創文章,作者:小藍,如若轉載,請註明出處:https://www.506064.com/zh-tw/n/237695.html