PowerShell 配置为启动时自动激活 Conda 环境

PowerShell 配置为启动时自动激活 Conda 环境

flyfish

查询配置文件路径

cpp 复制代码
$PROFILE
C:\Users\flyfish\Documents\WindowsPowerShell\Microsoft.PowerShell_profile.ps1

这个文件 Microsoft.PowerShell_profile.ps1 是 PowerShell 的开机自启配置文件
每次打开 PowerShell ,系统都会自动运行这个文件里的所有内容

Microsoft.PowerShell_profile.ps1内容

powershell 复制代码
#region conda initialize
# !! Contents within this block are managed by 'conda init' !!
If (Test-Path "C:\Users\flyfish\miniconda3\Scripts\conda.exe") {
    (& "C:\Users\flyfish\miniconda3\Scripts\conda.exe" "shell.powershell" "hook") | Out-String | ?{$_} | Invoke-Expression
}
#endregion

Conda 自动生成的初始化脚本

检查电脑里的 miniconda3 是否存在

如果存在,就把 Conda 功能加载到 PowerShell 里

让你可以在终端用 conda 命令

增加一句

cpp 复制代码
conda activate agent

每次打开 PowerShell,自动执行激活 agent 环境的命令,所以默认环境变成了agent

Conda 环境变量查询

复制代码
Get-ChildItem Env: | Where-Object Name -like "*CONDA*"

这个命令的作用:列出电脑里所有和 Conda 相关的系统配置

变量名 你的值 通俗解释
CONDA_EXE C:\Users\flyfish\miniconda3\Scripts\conda.exe Conda 程序位置 → Miniconda3
CONDA_DEFAULT_ENV agent 当前默认激活的环境 → 就是 agent
CONDA_PREFIX C:\Users\flyfish\.conda\envs\agent agent 环境的安装文件夹
CONDA_PROMPT_MODIFIER (agent) 终端前面显示的括号前缀
CONDA_SHLVL 2 正常(代表激活了1个自定义环境)
相关推荐
winfredzhang2 天前
用 wxPython 打造「Claude Code 任务启动器」:一个把 AI CLI 变成一键工作流的桌面工具
python·wxpython·powershell·剪贴板·claudecodecli
烟锁池塘柳02 天前
Conda 创建环境报错:Unable to read repodata JSON file,清华源 pkgs/free 失效解决方法
json·conda
veminhe2 天前
conda使用
python·conda
鬼手点金3 天前
Hermes‑Agent 使用教程
python·ubuntu·powershell·cmd·ai agent·opencode·hermes
方与圆之帆7 天前
conda 管理不同版本的软件包
conda·gdal·osm
数智工坊8 天前
Conda 环境 Docker 标准化迁移完整方案,适配深度学习 GPU 训练
深度学习·docker·conda
寒水馨9 天前
macOS下载、安装PowerShell-v7.6.4(附安装包powershell-7.6.4-osx-arm64.pkg)
macos·自动化·跨平台·shell·脚本·命令行·powershell
寒水馨9 天前
Linux下载、安装PowerShell-v7.6.4(附安装包powershell-7.6.4-linux-x64.tar.gz)
linux·跨平台·自动化运维·devops·命令行·powershell·脚本语言
软糖姐姐10 天前
Python开篇——简介、pip和conda
python·conda·pip·数据科学·
puamac11 天前
Conda + CUDA 环境安装与使用完全指南
conda