1. Install Python

  • Python V3.12.3;D:/Install/Dev/Python;

python -V && pip -V

Python 3.12.3
pip 24.0

2. Install Conda

conda --version && conda info --envs

conda 	24.1.2
base    D:\Install\Dev\Conda

3. Optional Install Navigator

conda install anaconda-navigator -y
  • 官方说安装Anaconda Distribution自带Navigator,实际无法正常运行;

  • 搜索栏搜索:Anaconda Navigator,然后固定到开始屏幕,以管理员方式运行;

  • 向下滚动滑轮,选择安装JupyterLab,点击Launch启动

  • Anaconda Navigator界面字体过小,设置环境变量:QT_SCALE_FACTOR=1.5

4. Repository notebook-jupyter

  • 创建Gitee仓库:D:\Install\Dev\workspace\jupyter-module

5. Create Directory

# PowerShell执行

@('data','config','search','runtime','notebook','workspace') |
    ForEach-Object {
        New-Item (Join-Path 'D:/Install/Dev/workspace/jupyter-module/' $_) -ItemType Directory -force
    }

6. Setup Environment Variable

  • 案例如:setx /M PATH "%%JAVA_HOME%%\bin;%PATH%;"

  • setEnvironmentVariable.bat,管理员身份运行

@echo 请以管理员身份运行

setx /M JUPYTER_BASE "D:/Install/Dev/workspace/jupyter-module"

setx /M JUPYTER_DATA_DIR "%%JUPYTER_BASE%%\data"
setx /M JUPYTER_CONFIG_DIR "%%JUPYTER_BASE%%\config"
setx /M JUPYTER_CONFIG_PATH "%%JUPYTER_BASE%%\search"
setx /M JUPYTER_RUNTIME_DIR "%%JUPYTER_BASE%%\runtime"
setx /M JUPYTERLAB_WORKSPACES_DIR "%%JUPYTER_BASE%%\workspace"

pause

7. Install Jupyter Lab

pip install jupyterlab jupyterlab-language-pack-zh-CN

8. Setup Configuration

cd d:

jupyter-lab --generate-config

D:/Install/Dev/workspace/jupyter-module/config/jupyter_lab_config.py

vim jupyter_lab_config.py

c.ServerApp.root_dir = 'D:\\Install\\Dev\\workspace\\jupyter-module\\notebook'

c.ServerApp.browser = 'D:/Install/System/Firefox/firefox.exe http://127.0.0.1:12345/lab --app=%s'

c.ServerApp.ip = '*'

c.ServerApp.port = 12345

c.ServerApp.allow_origin = '*'

# 其它配置或环境变量可酌情修改

9. Launch JupyterLab

cd D:\Install\Dev\workspace\jupyter-module

jupyter-lab

复制token,如:8df31971fba74a75ed1b0679ed250cee5d292ebead751ec9

10. JupyterLab Verification

http://127.0.0.1:12345/lab

键入token并设置密码:elf

停止JupyterLab后,重新启动JupyterLab

http://127.0.0.1:12345/lab,输入密码elf登录后操作

11. Common Command

$ jupyter -h
$ jupyter --version
$ jupyter --paths

$ jupyter-lab -h
$ jupyter labextension --help

jupyter notebook --version && jupyter lab --version

12. Jupyter Rust

  • Visual Studio Build Tool和Windows SDK

  • 安装时左边选择Desktop Dev with C++,
    右边选择Windows SDK;并自定义路径;具体查看Graal安装章节;

# rustc 1.75.0
rustc --version


conda --version

cd D:\Install\Green\JupyterRust

conda create -n jupyter-rust python=3 -y

# conda deactivate
conda activate jupyter-rust

conda install -c anaconda cmake -y

# cargo install evcxr_jupyter
# 安装时需大点内存,否则Compiling和Building会失败
cargo install --locked evcxr_jupyter --force

evcxr_jupyter --install

# 重新构建jupyter lab
jupyter lab build

# 查看Jupyter Available Kernel List
juyter lab kernelspec list

13. Optional Command

# 因Conda Navigator可页面安装,故此选项可选
# conda install -c conda-forge jupyterlab -y

# Optional:注意版本适配,ValueError: The extension "jupyterlab-plotly"
# doesn't yet JupyterLab support current version
# https://github.com/jupyterlab/jupyterlab/issues/14590
# jupyter labextension install jupyterlab-plotly

# conda search nodejs
# conda uninstall nodejs
conda install -c conda-forge nodejs=18.18.2 -y

14. Rust Verification

  • 打开Conda Navigator,启动Jupyter Lab,新建Rust Notebook

fn main(){
	println!("Hello, world!");
}
main();

15. Jupyter Starter

echo off
cls
chcp 65001

set JUPYTER_URL=D:/Install/Dev/workspace/jupyter-module

d:
cd %JUPYTER_URL%

jupyter-lab

16. Jupyter Loader

  • 将文件或文件夹复制到notebook目录

  • D:\Install\Dev\workspace\jupyter-module\notebook

17. Jupyter Execute Command

  • Execute Terminal Command in Jupyter Notebook

17.1. Via Magic Command

!ls

!pip install numpy

17.2. Via Subprocess Module

import subprocess

result = subprocess.run(['ls', '-l'], stdout=subprocess.PIPE)
print(result.stdout.decode())
import subprocess

result = subprocess.run(['./script.sh'],input=b'yes\n',encoding='utf-8',stdout=subprocess.PIPE)
print(result.stdout)

18. Bash Kernel

!pip install bash_kernel

!python -m bash_kernel.install

ls *.pth

ls -R DirectoryName