Alias for Python command on powershell giving the error : "Can't find a default Python."

Alias for Python command on powershell giving the error : "Can't find a default Python."

我在 PowerShell 上为 Python 命令创建了一个新别名,其中包含以下行:

New-Alias py Python

我的别名工作得很好,但是当我试图在另一个 powershell 实例中使用它时,它不起作用,我得到了错误:

Can't find a default Python.

是否仅为特定的 powershell 实例创建了别名?如果是,我如何才能将此别名设置为永久且可用于所有实例?

您需要在配置文件中设置别名,以使其在 Powershell 会话中保持不变。

https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_profiles?view=powershell-6