Chocolatey - Python - 我做错了吗?

Jay*_*van 6 chocolatey

我使用 Chocolatey 安装了 Python:

choco install python3
Run Code Online (Sandbox Code Playgroud)

我在管理 PowerShell 提示符下执行此操作。结果似乎足够成功:

PS C:\Windows\system32> choco install python3 --force
Installing the following packages:
python3
By installing you accept licenses for the packages.

python3 v3.6.0 (forced)
The package python3 wants to run 'chocolateyInstall.ps1'.
Note: If you don't run this script, the installation will fail.
Note: To confirm automatically next time, use '-y' or consider setting
 'allowGlobalConfirmation'. Run 'choco feature -h' for more details.
Do you want to run the script?
 1) yes
 2) no
 3) print
yes
 Downloading python3 64 bit
   from 'https://www.python.org/ftp/python/3.6.0/python-3.6.0-amd64.exe'
 Hashes match.
 Installing python3...
 python3 has been installed.
 Installed to 'C:\Python36'
 The install of python3 was successful.

Chocolatey installed 1/1 package(s). 0 package(s) failed.
 See the log for details (C:\ProgramData\chocolatey\logs\chocolatey.log).
Run Code Online (Sandbox Code Playgroud)

但是,我似乎没有 Python:

PS C:\Windows\system32> python
The term 'python' is not recognized as the name of a cmdlet,
Run Code Online (Sandbox Code Playgroud)

所以......也许它已安装,但不在我的PATH中?有什么方法可以让我知道它安装在哪里?

fer*_*der 7

在 Windows 中,您通常不能只安装某些东西并立即在命令行上使用它而不关闭并重新打开您的命令外壳。

然而,Chocolatey 附带了一个您可以运行的命令,称为“刷新环境”,或refreshenv简称为“刷新环境” 。通常,如果 PATH 更新,Chocolatey 会提醒您运行refreshenv以更新您的 shell。

这使您可以立即利用新安装的应用程序。

这是一个带注释的示例:

显示升级/路径更改/refreshenv

  • 早在 2021 年,在 choco 中安装 Python3.9 似乎出现了问题。它不会,但当来自 PS 的“python”时会创建到 MS Store 的链接。在 `C:\ProgramData\chocolatey\lib` 中有包含 nupkg 和 nuspec 的 python,但在 choco install python 后不再包含更多内容。我还收到错误: - python3 (exited 1603) - 运行“C:\ProgramData\chocolatey\lib\python3\tools\chocolateyInstall.ps1”时出错。有什么帮助吗? (3认同)