跳到主要内容

在 Windows 下,如何为你的 VSCode 配置 conda 环境

· 阅读需 1 分钟
Benjamin

安装 Conda

推荐采用简洁而同样强大的 MiniConda(https://docs.conda.io/projects/miniconda)

只是比Anaconda少了一些预装的模块.

Miniconda is a free minimal installer for conda. It is a small bootstrap version of Anaconda that includes only conda, Python, the packages they both depend on, and a small number of other useful packages (like pip, zlib, and a few others).

添加环境变量

参考 小白教程 | Miniconda安装及添加环境变量 原创

VSCode

下载参考 VScode——下载、安装、配置中文环境(windows)

vscode 选择 select python interpretor

可能需要 vscode 管理员权限

常用脚本

下载 requirements.txt

下载 requirements.txt 中的内容

while read requirement; do conda install --yes $requirement || pip install $requirement; done < requirements.txt

导入导出 *.yaml 配置文件

以 yaml 文件格式导入导出 conda 环境

# export
conda env export > <path_to_yaml_file>
# import
conda env create -f <path_to_yaml_file>
conda activate <environment_name>
Loading Comments...