简体   繁体   English

如何使用 Windows 命令提示符安装 Python

[英]How to install Python using Windows Command Prompt

Is it possible to install Python from cmd on Windows?是否可以在 Windows 上从 cmd 安装 Python? If so, how to do it?如果是这样,该怎么做?

https://docs.python.org/3.6/using/windows.html#installing-without-ui https://docs.python.org/3.6/using/windows.html#installing-without-ui

Installing Without UI: All of the options available in the installer UI can also be specified from the command line, allowing scripted installers to replicate an installation on many machines without user interaction.不使用 UI 安装:安装程序 UI 中的所有可用选项也可以从命令行指定,允许脚本安装程序在没有用户交互的情况下在多台机器上复制安装。 These options may also be set without suppressing the UI in order to change some of the defaults.也可以在不抑制 UI 的情况下设置这些选项以更改某些默认值。

To completely hide the installer UI and install Python silently, pass the /quiet option.要完全隐藏安装程序 UI 并静默安装 Python,请传递 /quiet 选项。 To skip past the user interaction but still display progress and errors, pass the /passive option.要跳过用户交互但仍显示进度和错误,请传递 /passive 选项。 The /uninstall option may be passed to immediately begin removing Python - no prompt will be displayed.可以传递 /uninstall 选项以立即开始删除 Python - 不会显示提示。

All other options are passed as name=value, where the value is usually 0 to disable a feature, 1 to enable a feature, or a path.所有其他选项都作为 name=value 传递,其中值通常是 0 表示禁用功能,1 表示启用功能或路径。

Assuming that you have python-installer.exe file you can run in in /passive mode in administrator window.假设您有python-installer.exe文件,您可以在管理员窗口中以/passive模式运行。 Without administrator privileges you will be prompted没有管理员权限会提示你

Do you want to allow this app to make changes to your device?您要允许此应用对您的设备进行更改吗?

Powershell example could be: Powershell 示例可能是:

$installer = "C:/tmp/python-3.7.6-amd64.exe"
& $installer /passive InstallAllUsers=1 PrependPath=1 Include_test=0

For Windows对于Windows

I was unable to find a way to Download python using just CMD but if you have python.exe in your system then you can use the below Method to install it (you can also make .bat file to automate it.)我无法找到一种仅使用 CMD 下载 python 的方法,但是如果您的系统中有 python.exe,那么您可以使用下面的方法来安装它(您也可以制作 .bat 文件来自动化它。)

  1. Install the python.exe file on your computer from the official site.从官方网站在您的计算机上安装 python.exe 文件。

  2. Open CMD and change Your directory to the path where you have python.exe打开 CMD 并将您的目录更改为您拥有 python.exe 的路径

  3. Past this code in your Command prompt make sure to change the name with your file version In the below code(eg python-3.8.5.exe)在您的命令提示符中粘贴此代码,确保使用您的文件版本更改名称在下面的代码中(例如 python-3.8.5.exe)

python-3.6.0.exe /quiet InstallAllUsers=1 PrependPath=1 Include_test=0

It will also set the path Variables.它还将设置路径变量。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何使用 windows 命令提示从 .tar.xz 安装 Python - How to install Python from .tar.xz using windows command Prompt 如何使用Python子进程启动Windows命令提示符? - How to launch Windows command prompt using Python subprocess? 如何使用Python在Windows命令提示符下使用颜色? - How do I use colour with Windows command prompt using Python? 在 Windows 命令提示符下使用“python -c”选项 - Using 'python -c' option in Windows command prompt 如何在Windows中创建3个命令提示符实例,并使用python将命令并行传递给每个提示符 - How to create 3 instances of command prompt in Windows and pass commands to each prompt in parallel using python 如何在 Windows 命令提示符下运行 python 文件? - How to run a python file in the windows command prompt? 如何从 windows 命令提示符中杀死 python? - how to kill python from windows command prompt? 如何在 windows 命令提示符上使用 python 模块 - How to use python module on windows command prompt 在Windows命令提示符下使用python的子进程或命令模块 - Using the subprocess or Command module of python for Windows command prompt 如何在Windows上使用命令行在Python中的项目中安装软件包? - How to install packages inside a project in python using command line on Windows?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM