更新PowerShell后无法使用conda:usage: conda-script.py [-h] [-v] [--no-plugins] [-V] COMMAND ...

我更新后遇到的问题如图。

附解决方法:

1、首先确定环境变量与powershell都配置完毕

2、编辑powershell的配置文件:

notepad $PROFILE

3、将下列代码放到上述文件结尾,注意将conda.exe的文件路径换为自己的安装路径

Write-Host "Running 4th: CurrentUserCurrentHost" -ForegroundColor Magenta
Write-Host "Path: $($PROFILE.CurrentUserCurrentHost)" -ForegroundColor Magenta

# Conda Initialization
(& "D:\anaconda\Scripts\conda.exe" "shell.powershell" "hook") | Out-String | ?{$_} | Invoke-Expression

# Fix for Conda issue in PowerShell 7.5+ (caused by .NET 9 changes)
if ($PSVersionTable.PSVersion -ge [version]"7.5.0") {
    $ExecutionContext.InvokeCommand.PreCommandLookupAction = {
        param ($CommandName, $CommandOrigin)
        if ($CommandName -eq "conda") {
            $Env:_CE_M = $null
            $Env:_CE_CONDA = $null
        }
    }
}

如图

4、是配置文件生效:

. $PROFILE

然后问题解决:

原帖:

anaconda - `Invoke-Conda` cannot catch any arguments after powershell 7.5.0 update - Stack Overflow

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值