powershell7存在的坑点,conda:Invoke-Expression: Missing argument in parameter list.

正文

github上放的powershell,是为全平台准备的,你可以看到他存在linux版本。
image

这是他的优点,不过,也是缺点。
当有一个软件编写ps1脚本,他肯定是为windows自带的powershell而设计的,而自带的powershell和这个github的powershell是有所不同的,存在兼容性问题。

MiniConda

新版的conda不存在兼容性问题,然而miniconda的版本更为老旧。
powershell的7.4.7版本不存在这个问题,也可以切换powershell的版本。我就懒得换了,conda我也不经常用。

(llamafactory) PS C:\Users\32956> conda --version
conda 4.9.2

conda和最新的powershell存在兼容问题,我一直以为是我哪里使用不当。
image

%windir%\System32\WindowsPowerShell\v1.0\powershell.exe -ExecutionPolicy ByPass -NoExit -Command "& 'C:\Users\32956\miniconda3\shell\condabin\conda-hook.ps1' ; conda activate 'C:\Users\32956\miniconda3' "

执行了两个命令,如下。我们到pwsh,也就是powershell7中,执行,到第二个命令会显示错误。

C:\Users\32956\miniconda3\shell\condabin\conda-hook.ps1;
conda activate 'C:\Users\32956\miniconda3'

image

miniconda的conda只有4.9左右的版本,非常低。conda后续的版本修复了这个问题,因此我们可以升级conda。

conda update conda

cursor

cursor中打开pwsh终端时,自动补全会显示一大堆路径。
详情可以看这个博客。
https://www.cnblogs.com/oldsaltfish/p/18639659

posted @ 2025-03-09 00:01  魂祈梦  阅读(915)  评论(0)    收藏  举报