Windows中使用包管理器(类似于apt/yum的) - Chocolatey

Windows中使用包管理器 - Chocolatey简介


李俊才 的 CSDN 博客
邮箱 :291148484@163.com
CSDN 主页https://blog.csdn.net/qq_28550263?spm=1001.2101.3001.5343
本文地址https://blog.csdn.net/qq_28550263/article/details/113103186

曾今有个段子,使用Linux系统前觉得Linux系统操作复杂度简直反人类,会用Linux系统后,觉得Windows在很多地方也挺反人类。用习惯了Windows的用户一般都会在特定的网站寻找一个安装包的可执行文件下载并安装软件,而使用Linux系统的用户更喜欢使用包管理器——只需要一行简单的命令,即可轻松安装需要的软件!

现在Windows上也有类似于Ubuntu的“apt”或CentOS的“yum”工具了!这就是“Chocolatey”。对于开发者而言使用包管理工具的便利性就不用多介绍了,本文将带领读者通过包管理器来搭建一些常用的开发环境以及安装一些常用软件。

1.Chocolatey简介

懒得简介了。

2.搭建Chocolatey包管理环境

Chocolatey的安装

Chocolatey要求的最低Windows系统版本为Windows7,并且需要:

  • PowerShell v2 +(虽然还不是PowerShell Core)(由于TLS 1.2要求,从此网站安装的最低版本是v3 )
  • .NET Framework 4+(Windows10以上系统自带而无需安装了)(由于TLS 1.2要求,从此网站安装的最低版本为4.5 )

满足以上要求下,请跟着本文进行以下操作:
右键Win菜单按钮,打开 WindowsPowerShell(管理员),如图所示:
在这里插入图片描述在这里插入图片描述
输入以下命令,下载安装Chocolatey:

Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))

如果你用的为cmd.exe而不是PowerShell,则应该使用如下命令(间接使用PowerShell):

@"%SystemRoot%\System32\WindowsPowerShell\v1.0\powershell.exe" -NoProfile -InputFormat None -ExecutionPolicy Bypass -Command "[System.Net.ServicePointManager]::SecurityProtocol = 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))" && SET "PATH=%PATH%;%ALLUSERSPROFILE%\chocolatey\bin"

安装过程中若出现(是否运行脚本):

Do you want to run the script?([Y]es/[A]ll - yes to all/[N]o/[P]rint):

则输入y并回车,程序安装运行,直到安装完成是,你将看到:

 The install of dart-sdk was successful.
  Software installed to 'C:\tools'

如果你的组织/企业禁用了PowerSell,那么很遗憾,你将无法使用Chocolatey。必须指出PowerShell是Windows自动化的主要内容,因此在当今这个时代,禁用PowerShell并不是组织的常识。

Chocolatey的升级

如果你的电脑上已经安装了Chocolatey环境,仅仅希望升级,类似于ubuntu中升级apt工具的apt updata,您可以在PowerShell中使用以下命令对Chocolatey进行升级:

choco upgrade chocolatey

该命令也可以对Chocolatey安装的其它包进行更新,比如已经安装了Python,希望更新Python的版本,则可以使用命令:

choco upgrade python

另外,对于使用node.js的windows用户来说,你很可能在专门了解Chocolatey前就已经安装使用过该工具。安装完成node.js的Windows版本后,菜单中有个为node.js安装额外工具的脚本,它在某些机器上会自动在主程序安装后运行,也可手动点击:
在这里插入图片描述
运行后将弹出一个cmd窗口:

====================================================
Tools for Node.js Native Modules Installation Script
====================================================

This script will install Python and the Visual Studio Build Tools, necessary
to compile Node.js native modules. Note that Chocolatey and required Windows
updates will also be installed.

This will require about 3 Gb of free disk space, plus any space necessary to
install Windows updates. This will take a while to run.

Please close all open programs for the duration of the installation. If the
installation fails, please ensure Windows is fully updated, reboot your
computer and try to run this again. This script can be found in the
Start menu under Node.js.

You can close this window to stop now. Detailed instructions to install these
tools manually are available at https://github.com/nodejs/node-gyp#on-windows

请按任意键继续. . .

不断回车确认,直到程序开始,这时候该程序将先安装chocolatey,然后打开一个PowerShell窗口使用该包管理工具继续安装Python3visual stdio等软件作为node.js的拓展工具,部分安装过程截图如下仅供参考:

Getting latest version of the Chocolatey package for download.
Getting Chocolatey from https://chocolatey.org/api/v2/package/chocolatey/0.10.15.
Extracting C:\Users\李俊才\AppData\Local\Temp\chocolatey\chocInstall\chocolatey.zip to C:\Users\李俊才\AppData\Local\Temp\chocolatey\chocInstall...
Installing chocolatey on this machine
Creating ChocolateyInstall as an environment variable (targeting 'Machine')
  Setting ChocolateyInstall to 'C:\ProgramData\chocolatey'
WARNING: It's very likely you will need to close and reopen your shell
  before you can use choco.
Restricting write permissions to Administrators
We are setting up the Chocolatey package repository.
The packages themselves go to 'C:\ProgramData\chocolatey\lib'
  (i.e. C:\ProgramData\chocolatey\lib\yourPackageName).
A shim file for the command line goes to 'C:\ProgramData\chocolatey\bin'
  and points to an executable in 'C:\ProgramData\chocolatey\lib\yourPackageName'.

Creating Chocolatey folders if they do not already exist.

WARNING: You can safely ignore errors related to missing log files when
  upgrading from a version of Chocolatey less than 0.9.9.
  'Batch file could not be found' is also safe to ignore.
  'The system cannot find the file specified' - also safe.
警告: Not setting tab completion: Profile file does not exist at
'C:\Users\李俊才\Documents\WindowsPowerShell\Microsoft.PowerShell_profile.ps1'.
Chocolatey (choco.exe) is now ready.
You can call choco from anywhere, command line or powershell by typing choco.
Run choco /? for a list of functions.
You may need to shut down and restart powershell and/or consoles
 first prior to using choco.
Ensuring chocolatey commands are on the path
Ensuring chocolatey.nupkg is in the lib folder
Chocolatey v0.10.15
Upgrading the following packages:
python;visualstudio2017-workload-vctools
By upgrading you accept licenses for the packages.
python is not installed. Installing...
Progress: Downloading python3 3.9.1... 100%
Progress: Downloading python3 3.9.1... 100%
Progress: Downloading vcredist2015 14.0.24215.20170201... 100%
Progress: Downloading vcredist2015 14.0.24215.20170201... 100%
Progress: Downloading python 3.9.1... 100%
Progress: Downloading python 3.9.1... 100%

vcredist2015 v14.0.24215.20170201 [Approved]
vcredist2015 package files upgrade completed. Performing other installation steps.
 The upgrade of vcredist2015 was successful.
  Software install location not explicitly set, could be in package or
  default install location if installer.

python3 v3.9.1 [Approved]
python3 package files upgrade completed. Performing other installation steps.
Installing 64-bit python3...
WARNING: Generic MSI Error. This is a local environment error, not an issue with a package or the MSI itself - it could mean a pending reboot is necessary prior to install or something else (like the same version is already installed). Please see MSI log if available. If not, try again adding '--install-arguments="'/l*v c:\python3_msi_install.log'"'. Then search the MSI Log for "Return Value 3" and look above that for the error.
ERROR: Running ["C:\ProgramData\chocolatey\lib\python3\tools\python-3.9.1-amd64.exe" /quiet InstallAllUsers=1 PrependPath=1 TargetDir="C:\Python39" ] was not successful. Exit code was '1603'. Exit code indicates the following: Generic MSI Error. This is a local environment error, not an issue with a package or the MSI itself - it could mean a pending reboot is necessary prior to install or something else (like the same version is already installed). Please see MSI log if available. If not, try again adding '--install-arguments="'/l*v c:\python3_msi_install.log'"'. Then search the MSI Log for "Return Value 3" and look above that for the error..
The upgrade of python3 was NOT successful.
Error while running 'C:\ProgramData\chocolatey\lib\python3\tools\chocolateyInstall.ps1'.
 See log for details.

python v3.9.1 [Approved]
python package files upgrade completed. Performing other installation steps.
 The upgrade of python was successful.
  Software install location not explicitly set, could be in package or
  default install location if installer.
visualstudio2017-workload-vctools is not installed. Installing...
Progress: Downloading chocolatey-visualstudio.extension 1.8.1... 100%
Progress: Downloading chocolatey-visualstudio.extension 1.8.1... 100%
Progress: Downloading chocolatey-visualstudio.extension 1.8.1... 100%
Progress: Downloading visualstudio2017-workload-vctools 1.3.2... 100%
Progress: Downloading visualstudio2017-workload-vctools 1.3.2... 100%
Progress: Downloading visualstudio2017-workload-vctools 1.3.2... 100%
Progress: Downloading visualstudio-installer 2.0.1... 100%
Progress: Downloading visualstudio-installer 2.0.1... 100%
Progress: Downloading visualstudio-installer 2.0.1... 100%
Progress: Downloading visualstudio2017buildtools 15.9.31.0... 100%
Progress: Downloading visualstudio2017buildtools 15.9.31.0... 100%
Progress: Downloading visualstudio2017buildtools 15.9.31.0... 100%

chocolatey-visualstudio.extension v1.8.1 [Approved]
chocolatey-visualstudio.extension package files upgrade completed. Performing other installation steps.
 Installed/updated chocolatey-visualstudio extensions.
 The upgrade of chocolatey-visualstudio.extension was successful.
  Software installed to 'C:\ProgramData\chocolatey\extensions\chocolatey-visualstudio'

visualstudio-installer v2.0.1 [Approved]
visualstudio-installer package files upgrade completed. Performing other installation steps.
 The upgrade of visualstudio-installer was successful.
  Software install location not explicitly set, could be in package or
  default install location if installer.

visualstudio2017buildtools v15.9.31.0 [Approved]
visualstudio2017buildtools package files upgrade completed. Performing other installation steps.
Downloading channel manifest
  from 'https://aka.ms/vs/15/release/channel'
Progress: 100% - Completed download of C:\Users\李俊才\AppData\Local\Temp\chocolatey\chocolatey-visualstudio.extension\ChannelManifest_81725945.man (69.48 KB).
Download of ChannelManifest_81725945.man (69.48 KB) completed.
Downloading catalog manifest
  from 'https://download.visualstudio.microsoft.com/download/pr/010d871e-3fa8-4004-b219-1c10bcaa71ad/007e743d98343f0746d89c1e1466a533b5ce02dc8f2879b74bf9f5351fac14ea/VisualStudio.vsman'
Progress: 100% - Completed download of C:\Users\李俊才\AppData\Local\Temp\chocolatey\chocolatey-visualstudio.extension\Catalog_1250144725.man (7.94 MB).
Download of Catalog_1250144725.man (7.94 MB) completed.
Downloading visualstudio2017buildtools
  from 'https://download.visualstudio.microsoft.com/download/pr/010d871e-3fa8-4004-b219-1c10bcaa71ad/9140cad6afca4f123208c7be18c68a98b45a8e54c342cb15da8f8f242a63642c/vs_BuildTools.exe'
Progress: 100% - Completed download of C:\Users\李俊才\AppData\Local\Temp\chocolatey\visualstudio2017buildtools\15.9.31.0\vs_BuildTools.exe (1.2 MB).
Download of vs_BuildTools.exe (1.2 MB) completed.
Hashes match.
Installing visualstudio2017buildtools...
Preparing: C:\Users\???\AppData\Local\Temp\chocolatey\73b9c8489010012f9ff5cfd1\vs_bootstrapper_d15\HelpFile\1055\help.html...
Preparing: C:\Users\???\AppData\Local\Temp\chocolatey\73b9c8489010012f9ff5cfd1\vs_bootstrapper_d15\HelpFile\3082\help.html...
Preparing: C:\Users\???\AppData\Local\Temp\chocolatey\73b9c8489010012f9ff5cfd1\vs_bootstrapper_d15\HelpFile\1036\help.html...

Preparing: C:\Users\???\AppData\Local\Temp\chocolatey\73b9c8489010012f9ff5cfd1\vs_bootstrapper_d15\Microsoft.VisualStudio.Setup.Engine.dll...

Preparing: C:\Users\???\AppData\Local\Temp\chocolatey\73b9c8489010012f9ff5cfd1\vs_bootstrapper_d15\Microsoft.VisualStudio.Telemetry.dll...


WARNING: [7444] vs_setup_bootstrapper
WARNING: Waiting for the processes to finish...
WARNING: Found 5 still running Visual Studio installer processes:
WARNING: [11196] vs_installer
WARNING: [16708] vs_installerservice
WARNING: [7784] vs_installershell
WARNING: [11828] vs_installershell
WARNING: Waiting for the processes to finish...
WARNING: vs_installerservice process 16708 exited with code -1
visualstudio2017buildtools has been installed.
  visualstudio2017buildtools may be able to be automatically uninstalled.
 The upgrade of visualstudio2017buildtools was successful.
  Software installed to '"C:\Program Files (x86)\Microsoft Visual Studio\Installer"'

visualstudio2017-workload-vctools v1.3.2 [Approved]
visualstudio2017-workload-vctools package files upgrade completed. Performing other installation steps.
Installing visualstudio2017-workload-vctools...


2021-01-25T15:18:51 : Verbose : Received the application ready notification

2021-01-25T15:18:51 : Verbose : ProgressBarService listening to ipc channel: progress-bar

2021-01-25T15:18:51 : Verbose : LoggerIpcRpcService listening to ipc channel: LoggerService

...

3.使用Chocolatey安装常用的开发环境/软件

这里仅仅列举了一部分常用软件的安装命令,更多软件应该在Chocolatey包库中搜索。

安装Chocolatey GUI

choco install chocolateygui

运行时你将看到:

Chocolatey v0.10.15
Installing the following packages:
chocolateygui
By installing you accept licenses for the packages.
Progress: Downloading ChocolateyGUI 0.17.2... 100%
Progress: Downloading chocolatey-core.extension 1.3.5.1... 100%
Progress: Downloading DotNet4.5.2 4.5.2.20140902... 100%

chocolatey-core.extension v1.3.5.1 [Approved]
chocolatey-core.extension package files install completed. Performing other installation steps.
 Installed/updated chocolatey-core extensions.
 The install of chocolatey-core.extension was successful.
  Software installed to 'C:\ProgramData\chocolatey\extensions\chocolatey-core'

DotNet4.5.2 v4.5.2.20140902 [Approved]
dotnet4.5.2 package files install completed. Performing other installation steps.
The package DotNet4.5.2 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:
choco feature enable -n allowGlobalConfirmation
Do you want to run the script?([Y]es/[A]ll - yes to all/[N]o/[P]rint): y

Microsoft .Net 4.5.2 Framework is already installed on your machine.
 The install of dotnet4.5.2 was successful.
  Software install location not explicitly set, could be in package or
  default install location if installer.

ChocolateyGUI v0.17.2 [Approved]
chocolateygui package files install completed. Performing other installation steps.
The package ChocolateyGUI 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:
choco feature enable -n allowGlobalConfirmation
Do you want to run the script?([Y]es/[A]ll - yes to all/[N]o/[P]rint): y

Installing ChocolateyGUI...
ChocolateyGUI has been installed.
Added C:\ProgramData\chocolatey\bin\chocolateygui.exe shim pointed to 'c:\program files (x86)\chocolatey gui\chocolateygui.exe'.
Added C:\ProgramData\chocolatey\bin\chocolateyguicli.exe shim pointed to 'c:\program files (x86)\chocolatey gui\chocolateyguicli.exe'.
  chocolateygui may be able to be automatically uninstalled.
 The install of chocolateygui was successful.
  Software installed as 'msi', install location is likely default.

完成后,你将在菜单看到有新安装的软件Chocolatey GUI,如图:
在这里插入图片描述
这是一款Chocolatey 的可视化工具。

安装Dart SDK

choco install dart-sdk

在这里插入图片描述

安装docker

choco install docker-desktop

安装Python(默认当前的最新版本)

choco install python

如果用的是Python2,则可以使用命令

choco install python2

安装pip工具(Python安装软件包管理)

choco install pip

安装Anaconda(数据科学最受信任的Python发行版)

choco install anaconda3

安装Miniconda(Anaconda的mini版)

choco install miniconda3

安装JetBrains PyCharm(Python和科学开发的轻量级IDE)

choco install pycharm-community

安装Wing Python IDE(Wing Pro是专为专业程序员设计的功能齐全的Python IDE)

choco install wingide

安装Node.js

choco install nodejs.install

安装Java运行环境(JRE)

choco install javaruntime

安装Java8开发工具包(JDK)

choco install jdk8

安装Android SDK

choco install android-sdk

安装Android Studio

choco install androidstudio

安装OpenJDK(Oracle提供的开源Java开发工具包)

choco install openjdk

安装Go lang

choco install golang

安装Cppcheck(静态C / C ++代码分析工具)

choco install cppcheck

安装PHP

choco install php

安装Ruby

choco install ruby

安装Sass

choco install sass

安装Ghostscript(PostScript语言和PDF的解释器)

choco install Ghostscript

安装vim工具

choco install vim

安装OpenCV

choco install opencv

安装Rufus

choco install rufus

安装FileZilla Server(跨平台免费的FTP解决方案)

choco install filezilla.server

安装Putty(Windows和Unix平台的Telnet和SSH的免费实现)

choco install putty.install

安装NotePad++

choco install notepadplusplus

安装VisualStudio Code

choco install vscode

安装Eclipse

choco install eclipse

安装inkscape(Python编写的开源矢量图软件)

choco install inkscape

安装blender(带有Python接口的3D开源绘图软件)

choco install blender

安装OpenVPN(远程桌面软件)

choco install openvpn

安装SQLite

choco install sqlite

安装MySQL Community Server(开源数据库MySQL )

choco install mysql

安装MySQL Workbench

choco install mysql.workbench

安装PostgreSql

choco install postgresql

安装MongoDB(用C ++编写的可扩展,高性能,开源NoSQL数据库)

choco install mongodb.install

安装DBeaver-社区版

choco install dbeaver

安装DB Browser for SQLite

choco install sqlitebrowser

安装GitHub桌面

choco install github-desktop

安装GitKraken(直观,快速,美观的跨平台Git客户端。)

choco install gitkraken

安装SmartFTP(FTP,FTPS,SFTP,HTTP,Amazon S3,WebDAV,Google Drive,Google Cloud Storage,Microsoft OneDrive,Telnet,终端客户端)

choco install smartftp

安装WinSCP

choco install winscp.install

安装VMware Workstation

choco install vmwareworkstation

安装vmware-tools(Windows系统实用程序,用于在VSphere下运行的VM)

choco install vmware-tools

安装Google Chrome浏览器

choco install google-chrome-x64

安装Mozilla Firefox浏览器

choco install firefoxesr

安装Windows的Linux环境 - Cygwin

choco install cygwin

安装Chromium 浏览器

choco install chromium

安装ConEmu (控制台仿真器))

choco install conemu

安装Microsoft .NET Framework 4.6.1

choco install dotnet4.6.1

安装7Zip

choco install 7zip.portable

安装VisualStudio2017

choco install visualstudio2017enterprise

安装Sublime Text

choco install sublimetext3

安装JetBrains IntelliJ IDEA (Java编辑器)

choco install intellijidea-community

安装NetWide Assembler (针对Intel x86系列处理器的汇编程序)

choco install nasm

安装MinGW-w64(适用于Windows 64和32位的GCC。)

choco install mingw

安装OBS Studio(免费和开源软件,用于视频录制和实时流。)

choco install obs-studio

安装ShareX(屏幕截图工具)

choco install sharex

适用于Linux的Windows子系统

choco install wsl
  • 11
    点赞
  • 18
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 4
    评论
评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

jcLee95

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值