多语言展示
当前在线:1083今日阅读:26今日分享:39

chocolatey安装失败,莫名其妙报错的解决办法

如果用chocolatey官网的方法可以正常安装没有问题的话,估计不会看到我这个说明,但是我发这个教程的原因只是想给那些和我遇到同样问题的朋友,多一个可以解决的方法,也希望我的方法可以帮你解决和我遇到的同样的问题。
工具/原料
1

Windows 7+

2

powershell V2+

3

.NET Framework 4+

4

chocolatey

chocolatey安装时碰到的问题
1

1.首先说下出现的问题:●当你在CMD管理员模式下运行以下chocolatey官方安装命令之后→@'%SystemRoot%\System32\WindowsPowerShell\v1.0\powershell.exe' -NoProfile -ExecutionPolicy Bypass -Command 'iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))' && SET 'PATH=%PATH%;%ALLUSERSPROFILE%\chocolatey\bin'Getting latest version of the Chocolatey package for download.Getting Chocolatey from https://chocolatey.org/api/v2/package/chocolatey/0.10.13.Extracting C:\Users\Administrator\AppData\Local\Temp\chocolatey\chocInstall\chocolatey.zip to C:\Users\Administrator\AppData\Local\Temp\chocolatey\chocInstall...●会出现如下错误→使用“0”个参数调用“Start”时发生异常:“指定的可执行文件不是此操作系统平台的有效应用程序。”所在位置 行:206 字符: 3+   $process.Start() | Out-Null+   ~~~~~~~~~~~~~~~~~~~~~~~~~~~    + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException    + FullyQualifiedErrorId : Win32Exception使用“0”个参数调用“BeginOutputReadLine”时发生异常:“StandardOut 未重定向或者该进程尚未启动。”所在位置 行:207 字符: 3+   $process.BeginOutputReadLine()+   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~    + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException    + FullyQualifiedErrorId : InvalidOperationException使用“0”个参数调用“WaitForExit”时发生异常:“没有与此对象关联的进程。”所在位置 行:208 字符: 3+   $process.WaitForExit()+   ~~~~~~~~~~~~~~~~~~~~~~    + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException    + FullyQualifiedErrorId : InvalidOperationExceptionUnable to unzip package using 7zip. Perhaps try setting $env:chocolateyUseWindowsCompression = 'true' and call installagain. Error: 7-Zip signalled an unknown error (code )所在位置 行:220 字符: 15+ ...   default { throw '$errorMessage 7-Zip signalled an unknown error (co ...+                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~    + CategoryInfo          : OperationStopped: (Unable to unzip...n error (code ):String) [], RuntimeException    + FullyQualifiedErrorId : Unable to unzip package using 7zip. Perhaps try setting $env:chocolateyUseWindowsCompression = 'true' and call install again. Error: 7-Zip signalled an unknown error (code )

2

2.问题:同样你在powershelll(管理员模式)下运行运行Get-ExecutionPolicy。 如果它返回Restricted,则运行Set-ExecutionPolicy AllSigned或Set-ExecunitionPolicy Bypass -Scope Process。然后你会运行如下安装命令:Set-ExecutionPolicy Bypass -Scope Process -Force; iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))但是会出现和之前一样的错误提示。

3

3.问题:然后我又在网上搜索了这条信息。根据Chocolatey官网的安装说明介绍,只需在PowerShell v3+ (以管理员身份运行)中执行一条命令便可完成Chocolatey的安装了,如下所示:iwr https://chocolatey.org/install.ps1 -UseBasicParsing | iex在PowerShell中执行该命令后提示如下错误信息。Installing chocolatey on this machine & : 无法加载文件 C:\Users\Admin\AppData\Local\Temp\chocolatey\chocInstall\tools\chocolateyInstall.ps1,因为在此系统上 禁止运行脚本。有关详细信息,请参阅 http://go.microsoft.com/fwlink/?LinkID=135170 中的 about_Execution_Policies。 所在位置 行:245 字符: 3 + & $chocInstallPS1 +   ~~~~~~~~~~~~~~~    + CategoryInfo          : SecurityError: (:) [],PSSecurityException    + FullyQualifiedErrorId : UnauthorizedAccess

解决方法

4.写这么多问题,是为了方便遇到同样问题的人可以搜索到这个信息。现在说下解决方法:大家可以在第一个问题输出提示的最下方看到这个信息:前面一堆错误暂时忽略,下面有个错误    + FullyQualifiedErrorId : Unable to unzip package using 7zip. Perhaps try setting $env:chocolateyUseWindowsCompression = 'true' and call install again. Error: 7-Zip signalled an unknown error (code )这个似乎是无法解压的问题,根据错误提示执行如下命令,使Chocolatey使用系统的压缩功能。根据提示在powershell(管理员模式)下运行如下命令:$env:chocolateyUseWindowsCompression = 'true'然后在运行安装命令iwr https://chocolatey.org/install.ps1 -UseBasicParsing | iex如果没有提示任何错误,恭喜你你已经安装成功了。是不是很简单呢?(如图)你可以用choco -v这个命令测试下,是否安装成功。真心希望本方法可以帮助那些电脑不是很熟练的人解决问题。

推荐信息