缺省控制台设置为conda 的langchain
-
打开 VS Code 并安装 Python 扩展:
- 确保已安装 VS Code 的 Python 扩展(由 Microsoft 提供)。
-
选择 Conda 环境作为 Python 解释器:
- 按
Ctrl+Shift+P(或Cmd+Shift+P)打开命令面板。 - 输入并选择
Python: Select Interpreter。 - 从列表中选择你的 Conda 环境(例如
langchain-env)。它通常显示为类似Python 3.9.x ('langchain-env': conda)的选项。 - 如果未看到环境,点击“刷新”图标或手动输入 Conda 环境的 Python Says:
C:\Users\<你的用户名>\Anaconda3\envs\langchain-env\python.exe。
- 按
-
设置终端为 Conda 环境:
- 默认情况下,VS Code 的终端可能不会自动激活 Conda 环境。为确保终端使用
langchain-env:- 按
Ctrl+Shift+P,输入并选择Preferences: Open Settings (JSON)。 - 在
settings.json文件中,添加或更新以下配置:
- 按
- 默认情况下,VS Code 的终端可能不会自动激活 Conda 环境。为确保终端使用
{
"window.commandCenter": 1,
"diffEditor.hideUnchangedRegions.enabled": true,
"explorer.confirmDelete": false,
"terminal.integrated.profiles.windows": {
"Conda (langchain)": {
"path": "C:\\Windows\\System32\\cmd.exe",
"args": ["/K", "activate langchain"]
}
},
"terminal.integrated.defaultProfile.windows": "Conda (langchain)",
"terminal.integrated.automationProfile.windows": {
"path": "C:\\Windows\\System32\\cmd.exe",
"args": ["/K", "activate langchain"]
},
"terminal.external.windowsExec": "C:\\Windows\\System32\\cmd.exe /K activate langchain"
}