Appearance
conda、uv 和 jupyter
conda
创建环境
bash
conda create -n dl-jupyter python=3.11列出环境
bash
conda env list激活环境
bash
conda activate dl-jupyter退出环境
bash
conda deactivate删除环境
bash
conda remove -n dl-jupyter --alluv
运行程序
bash
uv run app.py安装包
bash
uv pip install fastapi uvicorn dotenv socksio卸载包
bash
uv pip uninstall requests列出包
bash
uv pip list
# 仅列出非依赖包
uv run python -m pip list --not-required导出包
bash
uv pip freeze > requirements.txt
# 仅导出非依赖包
uv run python -m pip list \
--not-required \
--format=freeze > requirements-manual.txtjupyter
本地启动
bash
jupyter lab
#jupyter notebook配置 conda 虚拟环境到 jupyter
bash
uv pip install ipykernel
python3 -m ipykernel install --user --name english-asr --display-name "conda (english-asr)"删除 jupyter 的 conda 虚拟环境
bash
jupyter kernelspec remove english-asr配置自动补全:
- 开启代码自动补全 Settings -> Code Completion -> Enable autocompletion
- 开启括号自动补全 Settings -> Auto Close Brackets
实战:准备一个 jupyter 深度学习环境
bash
# 准备 conda 虚拟环境
conda create -n dl-jupyter python=3.10
conda activate dl-jupyter
# 安装包
uv pip install numpy pandas matplotlib
# uv pip install seaborn tqdm
uv pip install torch torchvision torchaudio \
--index-url https://download.pytorch.org/whl/cpu
# 将虚拟环境添加到 jupyter
uv pip install ipykernel
python -m ipykernel install --user \
--name dl-jupyter \
--display-name "Conda (dl-jupyter)"