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个自定义环境)
相关推荐
花间相见4 天前
【AI私人家庭医生day01】—— 项目介绍
大数据·linux·人工智能·python·flask·conda·ai编程
Zero_to_zero12344 天前
如何多机复用 conda 环境
conda
九河_5 天前
从requirements.txt中安装缺失的包
python·conda·pip·环境管理
Soari5 天前
Ziggo-CaaS-Switch软件配置教程
bash·powershell·tsn 交换机
从0至16 天前
Conda 命令指南:从入门到精通
python·conda·小项目
xiaotao1317 天前
阶段零:Python 安装与虚拟环境(venv / Conda)
开发语言·人工智能·python·conda
KANGBboy8 天前
anaconda 相关
python·conda
qq_白羊座9 天前
‌Miniconda 和 Conda 的关系
conda
萧行之11 天前
CONDA设置、查看、管理源
conda
LAM LAB11 天前
【shell】win10 Powershell字体美化
powershell