起因

近期折腾了一下Windows Terminal,安装配置了Powershell 7.3,然后发现conda activate在Powershell中用不了了,conda init powershell不起作用,conda init cmd.exe没有问题

分析

因为powershell的profile.ps1文件路径中存在中文,conda init powershell并没有修改到profile文件,也就没给powershell初始化。
在这里插入图片描述

解决

**方法一:**打开管理员终端,使用conda init --system --all,对系统中所有用户与终端进行初始化,详见conda init -h
**方法二:**自己在powershell的profile文件中加入初始化描述。输入notepad $profile打开profile文件,在最后一行加上下面语句(注意把conda.exe的路径修改成自己的):

# !! Contents within this block are managed by 'conda init' !!
(& "D:\Program_Files\Work\anaconda3\Scripts\conda.exe" "shell.powershell" "hook") | Out-String | Invoke-Expression
#endregion

参考

conda init命令排错
Powershell无法使用conda activate的问题

Logo

旨在为数千万中国开发者提供一个无缝且高效的云端环境,以支持学习、使用和贡献开源项目。

更多推荐