Peter Hsiao
    • Create new note
    • Create a note from template
      • Sharing URL Link copied
      • /edit
      • View mode
        • Edit mode
        • View mode
        • Book mode
        • Slide mode
        Edit mode View mode Book mode Slide mode
      • Customize slides
      • Note Permission
      • Read
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Write
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Engagement control Commenting, Suggest edit, Emoji Reply
    • Invite by email
      Invitee

      This note has no invitees

    • Publish Note

      Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

      Your note will be visible on your profile and discoverable by anyone.
      Your note is now live.
      This note is visible on your profile and discoverable online.
      Everyone on the web can find and read all notes of this public team.
      See published notes
      Unpublish note
      Please check the box to agree to the Community Guidelines.
      View profile
    • Commenting
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
      • Everyone
    • Suggest edit
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
    • Emoji Reply
    • Enable
    • Versions and GitHub Sync
    • Note settings
    • Note Insights
    • Engagement control
    • Transfer ownership
    • Delete this note
    • Save as template
    • Insert from template
    • Import from
      • Dropbox
      • Google Drive
      • Gist
      • Clipboard
    • Export to
      • Dropbox
      • Google Drive
      • Gist
    • Download
      • Markdown
      • HTML
      • Raw HTML
Menu Note settings Versions and GitHub Sync Note Insights Sharing URL Create Help
Create Create new note Create a note from template
Menu
Options
Engagement control Transfer ownership Delete this note
Import from
Dropbox Google Drive Gist Clipboard
Export to
Dropbox Google Drive Gist
Download
Markdown HTML Raw HTML
Back
Sharing URL Link copied
/edit
View mode
  • Edit mode
  • View mode
  • Book mode
  • Slide mode
Edit mode View mode Book mode Slide mode
Customize slides
Note Permission
Read
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Write
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Engagement control Commenting, Suggest edit, Emoji Reply
  • Invite by email
    Invitee

    This note has no invitees

  • Publish Note

    Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

    Your note will be visible on your profile and discoverable by anyone.
    Your note is now live.
    This note is visible on your profile and discoverable online.
    Everyone on the web can find and read all notes of this public team.
    See published notes
    Unpublish note
    Please check the box to agree to the Community Guidelines.
    View profile
    Engagement control
    Commenting
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    • Everyone
    Suggest edit
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    Emoji Reply
    Enable
    Import from Dropbox Google Drive Gist Clipboard
       owned this note    owned this note      
    Published Linked with GitHub
    Subscribed
    • Any changes
      Be notified of any changes
    • Mention me
      Be notified of mention me
    • Unsubscribe
    Subscribe
    --- tags: slide, Jupyter --- # JupyterLab<br>調整懶人包 ![](https://i.imgur.com/KIGnNVR.png) --- ## 目標:用起來像 MatLab <br>(或 RStudio) 預設的 JupyterLab 缺乏甚麼? - [ ] 啟動:點開捷徑就能啟動 - [ ] GUI:不要像瀏覽器(URL列、Tabs列不可出現、要有專屬狀態列) - [ ] 功能:程式碼美化、變數瀏覽、版本控制、文件結構樹狀大綱 - [ ] (加碼):多語言支援、fira code 字體 #### 這些通通有解!!! --- ## 啟動 JupyterLab 基本上高尚的大家應該要這樣開啟 ```shell cd "說好的資料夾" jupyter lab ``` --- 但我很懶怎麼辦?做捷徑(ICON [載點](https://github.com/jupyterlab/jupyterlab_app/blob/master/dist-resources/icon.ico)) ```shell ...\Anaconda3\Scripts\jupyter-lab.exe “說好的資料夾” ``` ![](https://i.imgur.com/NhrMy83.png) --- ## 以 chrome app mode 啟用 - 這樣還是會有醜醜的 URL 欄位,第一次建立 jupyter_notebook_config.py 檔案請使用命令 ```shell jupyter notebook --generate-config ``` - 執行後會回報位置資料夾,請至資料夾開啟 jupyter_notebook_config.py 增加設定 ```python c.NotebookApp.browser = ".../chrome.exe --app=%s" ``` --- 這樣就賞心悅目了~~ ![](https://i.imgur.com/t2s5ttj.png) --- - [x] 啟動:~~點開捷徑就能啟動~~ - [ ] GUI:不要像瀏覽器(~~URL列~~、~~Tabs列不可出現~~、要有專屬狀態列) - [ ] 功能:程式碼美化、變數瀏覽、版本控制、文件結構樹狀大綱 - [ ] (加碼):多語言支援、fira code 字體 --- 之後有些外掛也可能要修改設定,<br>大致上在以下五處: 1. `.../.jupyter/jupyter_notebook_config.py` 2. `.../.jupyter/custom/custom.js` 3. (Lab跟Notebook共通)View 選單 4. Lab 的 Setting 選單 5. Lab 的 Advanced Settings (Ctrl+,) --- ## 多重 Kernel 安裝 Jupyter 支援多重 Kernel (可執行的語言核心),加上 Anaconda 可以安裝虛擬版本的 Python 環境,所以我們的 Luncher 可以很壯觀: ![](https://i.imgur.com/4SpErGe.png) --- ### Python X.X.X/ X.X/ X 建立一個名叫 `py36` 的 Python 3.6 環境 加到 kernels 裡面叫做 `python3.6` 平常使用時會顯示「Python 3.6」: ```shell # -n 是虛擬環境命名 python= 是指定版本號(可以3,可以3.6,可以3.6.8) conda create -n py36 python=3.6 # 啟用環境 Windows 版 activate py36 # 啟用環境 Mac/Linux 版 source activate py36 # 在環境安裝 ipykernel pip install ipykernel # --name 後面接的是 kernels 命名 --display-name 後面接的是顯示名稱 python -m ipykernel install --user --name python3.6 --display-name "Python 3.6" # 退出虛擬環境 deactivate ``` --- #### 假如我們不想要了 ```shell jupyter kernelspec uninstall python3.6 # 假如不知道有那些 kernal 名稱用下面調來看 jupyter kernelspec list # 假如連虛擬環境都不要 conda env remove --name py36 # 假如不知道有那些虛擬環境名稱用下面調來看 conda env list ``` --- ### R Kernel ```R R install.packages('IRkernel', repos = 'https://cloud.r-project.org/') IRkernel::installspec(user = FALSE) ``` ### Juila Kernel ```julia julia using Pkg Pkg.add("IJulia") ``` --- - [x] 啟動:~~點開捷徑就能啟動~~ - [ ] GUI:不要像瀏覽器(~~URL列~~、~~Tabs列不可出現~~、要有專屬狀態列) - [ ] 功能:程式碼美化、變數瀏覽、版本控制、文件結構樹狀大綱 - [x] (加碼):~~多語言支援~~、fira code 字體 --- ## JupyterLab Extension Manager Setting -> Advanced Settings (Ctrl+,) 開啟設定,在 Extension Manager 加入 `{"enabled": true}` ![](https://i.imgur.com/YTvot0K.png) --- ### 安裝 node.js - 許多 Lab 的外掛都是用 node.js 或 npm 部屬,需要先安裝才能安裝外掛,Anaconda 可以用 conda 的方式安裝 node.js ```shell conda install nodejs ``` - 但上面的版本很舊,有些外掛會需要新版 node.js ,請至官網安裝最新的 LTS 版(長期支援版) --- 啟用 Extension Manager 之後就會出現這個介面 ![](https://i.imgur.com/DKZTp8L.png) --- ### 安裝外掛,以及要記得 Rebuild 1. 一般來說安裝外掛大致長這樣(不建議用剛剛的 Extension Manager 安裝) ```shell # 可能需要先透過 pip 或 conda 安裝其他東西 jupyter labextension install 外掛名稱 # 有些外掛會要求安裝後還有後續設定 # 有些透過 npm 部屬 npm i 外掛名稱 ``` 2. Rebuild JupyterLab ```shell jupyter lab build # 只有 jlpm 是例外 jlpm build ``` --- ## 有甚麼好 labextension 外掛? - 美化程式碼: `@ryantam626/jupyterlab_code_formatter` (須配合 Python Package `black`/`yapf`/`autopep8` 三者至少一個) - 變數監看: `@lckr/jupyterlab_variableinspector` - 自定義字體: `@deathbeds/jupyterlab-fonts` (搭配 `@deathbeds/jupyterlab-font-fira-code`) --- - Open .md With Notebook: `notedown`(非 labextension) - 支援 `ipywidgets`: `@jupyter-widgets/jupyterlab-manager` - 表格瀏覽:`jupyterlab-spreadsheet` - draw.io:`jupyterlab-drawio` - 目錄表:`@jupyterlab/toc` - 狀態列:`@jupyterlab/statusbar` --- - [x] 啟動:~~點開捷徑就能啟動~~ - [x] GUI:~~不要像瀏覽器~~(~~URL列~~、~~Tabs列不可出現~~、~~要有專屬狀態列~~) - [x] 功能:~~程式碼美化~~、~~變數瀏覽~~、版本控制(透過 Git 外掛)、~~文件結構樹狀大綱~~ - [x] (加碼):~~多語言支援~~、~~fira code 字體~~ - [x] (!再加碼):~~表格檔瀏覽~~、~~流程圖繪圖~~、(還沒介紹:互動模組整合) --- ## 之前避談的事情:<br>一些小的編輯器功能 (輔助線、程式碼折疊等) - 有外掛可以用 VS Code 取代預設編輯器但個人尚未嘗試成功 - Jupyter Notebook 的 nbextension 其實做得很好但 JupyterLab 目前無法使用 --- ### 展望:JupyterLab 1.0 - 官方說 1.0 版 2018 年底會出來,目前 alpha3 版,github 上顯示完成度約 88%。 - 官方宣稱未來 JupyterLab 1.0 會取代現在的 Jupyter Notebook 。 - 不過官方承諾應該會讓大多數 Jupyter Notebook 的外掛可以安裝於 JupyterLab 。 --- ### Notebook 的外掛大補帖 - 安裝 jupyter_contrib_nbextensions ```shell conda install -c conda-forge jupyter_contrib_nbextensions ``` - 之後進 Jupyter Notebook 設定即可 ![](https://i.imgur.com/ykHcTL4.png) --- ## 小結語:幾乎功能完整的 IDE ![](https://i.imgur.com/KIGnNVR.png)

    Import from clipboard

    Paste your markdown or webpage here...

    Advanced permission required

    Your current role can only read. Ask the system administrator to acquire write and comment permission.

    This team is disabled

    Sorry, this team is disabled. You can't edit this note.

    This note is locked

    Sorry, only owner can edit this note.

    Reach the limit

    Sorry, you've reached the max length this note can be.
    Please reduce the content or divide it to more notes, thank you!

    Import from Gist

    Import from Snippet

    or

    Export to Snippet

    Are you sure?

    Do you really want to delete this note?
    All users will lose their connection.

    Create a note from template

    Create a note from template

    Oops...
    This template has been removed or transferred.
    Upgrade
    All
    • All
    • Team
    No template.

    Create a template

    Upgrade

    Delete template

    Do you really want to delete this template?
    Turn this template into a regular note and keep its content, versions, and comments.

    This page need refresh

    You have an incompatible client version.
    Refresh to update.
    New version available!
    See releases notes here
    Refresh to enjoy new features.
    Your user state has changed.
    Refresh to load new user state.

    Sign in

    Forgot password

    or

    By clicking below, you agree to our terms of service.

    Sign in via Facebook Sign in via Twitter Sign in via GitHub Sign in via Dropbox Sign in with Wallet
    Wallet ( )
    Connect another wallet

    New to HackMD? Sign up

    Help

    • English
    • 中文
    • Français
    • Deutsch
    • 日本語
    • Español
    • Català
    • Ελληνικά
    • Português
    • italiano
    • Türkçe
    • Русский
    • Nederlands
    • hrvatski jezik
    • język polski
    • Українська
    • हिन्दी
    • svenska
    • Esperanto
    • dansk

    Documents

    Help & Tutorial

    How to use Book mode

    Slide Example

    API Docs

    Edit in VSCode

    Install browser extension

    Contacts

    Feedback

    Discord

    Send us email

    Resources

    Releases

    Pricing

    Blog

    Policy

    Terms

    Privacy

    Cheatsheet

    Syntax Example Reference
    # Header Header 基本排版
    - Unordered List
    • Unordered List
    1. Ordered List
    1. Ordered List
    - [ ] Todo List
    • Todo List
    > Blockquote
    Blockquote
    **Bold font** Bold font
    *Italics font* Italics font
    ~~Strikethrough~~ Strikethrough
    19^th^ 19th
    H~2~O H2O
    ++Inserted text++ Inserted text
    ==Marked text== Marked text
    [link text](https:// "title") Link
    ![image alt](https:// "title") Image
    `Code` Code 在筆記中貼入程式碼
    ```javascript
    var i = 0;
    ```
    var i = 0;
    :smile: :smile: Emoji list
    {%youtube youtube_id %} Externals
    $L^aT_eX$ LaTeX
    :::info
    This is a alert area.
    :::

    This is a alert area.

    Versions and GitHub Sync
    Get Full History Access

    • Edit version name
    • Delete

    revision author avatar     named on  

    More Less

    Note content is identical to the latest version.
    Compare
      Choose a version
      No search result
      Version not found
    Sign in to link this note to GitHub
    Learn more
    This note is not linked with GitHub
     

    Feedback

    Submission failed, please try again

    Thanks for your support.

    On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?

    Please give us some advice and help us improve HackMD.

     

    Thanks for your feedback

    Remove version name

    Do you want to remove this version name and description?

    Transfer ownership

    Transfer to
      Warning: is a public team. If you transfer note to this team, everyone on the web can find and read this note.

        Link with GitHub

        Please authorize HackMD on GitHub
        • Please sign in to GitHub and install the HackMD app on your GitHub repo.
        • HackMD links with GitHub through a GitHub App. You can choose which repo to install our App.
        Learn more  Sign in to GitHub

        Push the note to GitHub Push to GitHub Pull a file from GitHub

          Authorize again
         

        Choose which file to push to

        Select repo
        Refresh Authorize more repos
        Select branch
        Select file
        Select branch
        Choose version(s) to push
        • Save a new version and push
        • Choose from existing versions
        Include title and tags
        Available push count

        Pull from GitHub

         
        File from GitHub
        File from HackMD

        GitHub Link Settings

        File linked

        Linked by
        File path
        Last synced branch
        Available push count

        Danger Zone

        Unlink
        You will no longer receive notification when GitHub file changes after unlink.

        Syncing

        Push failed

        Push successfully